Actions

Actions allow you to trigger API requests, HTTP requests, send email, etc.

shopify.get(url: string)

Send GET request to Shopify API - View Docs

Example: Get all products
const { data } = await actions.shopify.get("/admin/api/2022-07/products.json")

shopify.post(url: string, object)

Send POST request to Shopify API - View Docs

Example: Add new product
await actions.shopify.post("/admin/api/2022-07/products.json", {
    product: {
      title: "Burton Custom Freestyle 151",
      body_html: "Good snowboard!",
      vendor: "Burton",
      product_type: "Snowboard",
      tags: "Barnes & Noble, John's Fav, Big Air"
    }
  })

shopify.put(url: string, data: object)

Send PUT request to Shopify API - View Docs

Example: Change a product
await actions.shopify.put("/admin/api/2022-07/products/632910392.json", {
  "product": {
    id: 632910392,
    published: true
  }
})

shopify.delete(url: string)

Send DELETE request to Shopify API - View Docs

Example: Delete product
await actions.shopify.delete("/admin/api/2022-07/products/12345.json")

shopify.graphql(query: string)

Send GraphQL request to Shopify API - View Docs

Example: Query name of the shop
await actions.shopify.graphql(`query { shop { name } }`)

shopify.tagCustomer(customerId: string, tag: string)

Shortcut for adding a tag to a customer.

Note: Counts as 2 actions, as the customer must be fetched before being tagged.

Example: Tag customer
await actions.shopify.tagCustomer("12345", "tag d")

shopify.tagOrder(orderId: string, tag: string)

Shortcut for adding a tag to an order.

Note: Counts as 2 actions, as the order must be fetched before being tagged.

Example: Tag order
await actions.shopify.tagOrder("12345", "tag d")

pg.query(connectionOptions: string | object, query: string, params?: []any)

Exposes the 'pg' library. The first argument is the connection string or object, but the following arguments conform to the libraries 'query' method.

For more, see the node-postgres documentation .

Example: Insering data into Postgres
await actions.pg.query(
  process.env.DATABASE_URL,
  'insert into test_orders (total) values ($1)',
  [ payload.total_price ]
)

http.get(url: string, config?: object)

Send a GET request to any URL.

For more, see the Axios docs .

Example: Get data via HTTP GET request
const { data } = await actions.http.get('http://my.api.com/thing/1')
console.log('do something with thing 1', data)

http.post(url: string, data: any, config?: object)

Send a POST request to any URL.

For more, see the Axios docs .

Example: Post data via HTTP POST request
const { data } = await actions.http.post('http://my.api.com/things', { a: 1 })
console.log('created a thing: { a: 1 }')

http.put(url: string, data: any, config?: object)

Send a PUT request to any URL.

For more, see the Axios docs .

Example: Put data via HTTP PUT request
const { data } = await actions.http.put('http://my.api.com/things/1', { a: 1 })
console.log('updated a thing with { a: 1 }')

http.delete(url: string, config?: object)

Send a DELETE request to any URL.

For more, see the Axios docs .

Example: Delete an item via a HTTP DELETE request
const { data } = await actions.http.delete('http://my.api.com/things/1', { a: 1 })
console.log('deleted a thing with { a: 1 }')

http.patch(url: string, data: any, config?: object)

Send a PATCH request to any URL.

For more, see the Axios docs .

Example: Put data via HTTP PATCH request
const { data } = await actions.http.patch('http://my.api.com/things/1', { a: 1 })
console.log('partially updated a thing with { a: 1 }')

email.send(config: object)

Send an email with either HTML or plain text.

Example: Send a HTML email
await actions.emails.send({
  to: '[email protected]',
  cc: [ '[email protected]', '[email protected]' ],
  subject: 'Just a note',
  body: `
    

Hi!

Let me know what you think about ${customer.email}.

` })
On this page