Backend API

Fields

id

objectId

The unique identifier for the event.

date_created

dateauto

Date and time the event was created.

date_updated

dateauto

Date and time the event was updated.

model

stringrequired

The name of the model for which the events are associated.

type

stringrequired

The trigger type for the event.

data

object

The data or payload of the event.

notes

string

Notes stored on the event's webhook.

user_id

objectId

ID of the user that configured the webhook which triggers the event.

webhooks_pending

int

The number of webhooks still pending to fire.

webhooks

array of Webhooks

An array of pending webhooks

The event model
{
  "model": "accounts",
  "type": "account.created",
  "data": {
    "email": "martinseptim@waynonpriory.net",
    "first_name": "Martin",
    "last_name": "Septim",
    "password": "theblades123",
    "email_optin": true,
    "currency": "USD",
    "name": "Martin Septim",
    "date_created": "2022-06-27T03:39:45.152Z",
    "type": "individual",
    "order_count": 0,
    "order_value": 0,
    "balance": 0,
    "id": "62b9268145139e0019e246ca"
  },
  "date_created": "2022-06-27T03:39:45.461Z",
  "date_updated": "2022-06-27T03:39:45.875Z",
  "webhooks_pending": 0,
  "id": "62b9268145139e0019e246cb"
}

Retrieve an existing event using the id that was returned during creation.

Arguments

id

objectId

The unique identifier for the event.

GETevents/{id}
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/events/{id}', {
});
The event model
{
  "user_id": "606f0fdd255b020caaa3f577",
  "model": "shipments",
  "type": "shipment.created",
  "data": {
    "order_id": "62bc642d912a9800199ea465",
    "items": [
      {
        "product_id": "628ba3c7499bba0019b1a961",
        "order_item_id": "62bc63892fafef0019eb2312",
        "quantity": 1,
        "id": "62bc64bc2fafef0019eb231f"
      },
      {
        "product_id": "628ba442499bba0019b1a96d",
        "order_item_id": "62bc639293cb7c0019423b5f",
        "quantity": 1,
        "id": "62bc64bc2fafef0019eb2320"
      },
      {
        "product_id": "628ba6011869c10019b41f70",
        "order_item_id": "62bc639e629aa900197ff786",
        "quantity": 1,
        "id": "62bc64bc2fafef0019eb2321"
      },
      {
        "product_id": "628ba67a1869c10019b41f76",
        "order_item_id": "62bc63a293cb7c0019423b63",
        "quantity": 1,
        "id": "62bc64bc2fafef0019eb2322"
      },
      {
        "product_id": "628ba6b7499bba0019b1a9b2",
        "order_item_id": "62bc63a793cb7c0019423b66",
        "quantity": 1,
        "id": "62bc64bc2fafef0019eb2323"
      },
      {
        "product_id": "628ba701499bba0019b1a9bb",
        "order_item_id": "62bc63aa93cb7c0019423b69",
        "quantity": 1,
        "id": "62bc64bc2fafef0019eb2324"
      }
    ],
    "service": "international",
    "tracking_code": null,
    "carrier": null,
    "notes": "Let's hope the packages get past the Gatekeeper...",
    "service_name": "International",
    "destination": {
      "name": "Sheogorath",
      "address1": "New Sheoth Palace",
      "address2": null,
      "city": "Shivering Isles",
      "state": "TX",
      "zip": "78757",
      "country": "US",
      "phone": null
    },
    "date_created": "2022-06-29T14:42:04.017Z",
    "number": "S100004",
    "id": "62bc64bc2fafef0019eb231e"
  },
  "date_created": "2022-06-29T14:42:04.272Z",
  "id": "62bc64bc2fafef0019eb2325"
}

Return a list of events.

Arguments

expand

string

Expand link fields and child collections by using the expand argument.

  • For example, expand=account would return a related customer account if one exists.

When the field represents a collection, you can specify the query limit.

  • For example, expand=variants:10 would return up to 10 records of the variants collection.

See expanding for more details.

fields

string

Returns only the specified fields in the result.

  • For example fields=name,slug would return only the fields name and slug in the response.

Supports nested object and array fields using dot-notation.

  • For example, items.product_id. The product id is always returned.

include

object

Include one or more arbitrary queries in the response which are potentially related to the main query.

See including for more details.

limit

int

Limit the number of records returned, ranging between 1 and 1000. Defaults to 15.

page

int

The page number of results to return given the specified or default limit.

search

string

A text search is performed using the search argument. Searchable fields are defined by the model.

  • For example, search=red would return records containing the word "red" anywhere in the defined text fields.

See searching for more details.

sort

string

Expression to sort results by using a format similar to a SQL sort statement.

  • For example, sort=name asc would return records sorted by name ascending.

See sorting for more details.

where

object

An object with criteria to filter the result.

  • For example, active=true would return records containing a field active with the value true.

It's also possible to use query operators, for example, $eq, $ne, $gt, and more.

See querying for more details.

GETevents/{id}
const swell = require('swell-node').init('store-id', 'secret-key');

await swell.get('/events', {
});
Response
{
  "count": 1105,
  "results": [
    {
      "user_id": "606f0fdd255b020caaa3f577",
      "model": "accounts",
      "type": "account.updated",
      "data": {
        "id": "62b1e36767145000197b2bd6",
        "shipping": {
          "first_name": "Runs-in-circles",
          "last_name": null,
          "company": "",
          "address1": "Shivering isles",
          "address2": null,
          "city": null,
          "zip": "34534",
          "country": "US",
          "state": "AL",
          "phone": null,
          "name": "Runs-in-circles",
          "account_address_id": "62bcb8ec629aa900197ffb8d"
        }
      },
      "date_created": "2022-06-29T20:41:17.225Z",
      "id": "62bcb8ed629aa900197ffb8f"
    },
    {
      "user_id": "606f0fdd255b020caaa3f577",
      "model": "accounts:addresses",
      "type": "account.address.created",
      "data": {
        "parent_id": "62b1e36767145000197b2bd6",
        "name": "Runs-in-circles",
        "first_name": "Runs-in-circles",
        "last_name": null,
        "address1": "Shivering isles",
        "address2": null,
        "city": null,
        "state": "AL",
        "zip": "34534",
        "country": "US",
        "phone": null,
        "company": null,
        "fingerprint": "0f1d3af32dd2dc0607c12ace5b2ea9c5",
        "date_created": "2022-06-29T20:41:16.931Z",
        "active": true,
        "id": "62bcb8ec629aa900197ffb8d"
      },
      "date_created": "2022-06-29T20:41:17.192Z",
      "id": "62bcb8ed629aa900197ffb8e"
    },
    {
      "model": "settings",
      "type": "setting.updated",
      "data": {
        "id": "store",
        "settings": {
          "date_updated": "2022-06-29T19:45:22.163Z"
        }
      },
      "date_created": "2022-06-29T19:45:22.598Z",
      "id": "62bcabd2bc89e4001a4c4ecf"
    },
    {
      "user_id": "606f0fdd255b020caaa3f577",
      "model": "settings",
      "type": "setting.updated",
      "data": {
        "id": "store",
        "settings": {
          "date_updated": "2022-06-29T19:40:52.478Z"
        }
      },
      "date_created": "2022-06-29T19:40:53.402Z",
      "id": "62bcaac5629aa900197ffb35"
    },
 {. . .},
}

These are the event types that are currently recorded in Swell, grouped by model. They use a common past tense naming convention and all models (including custom ones) have the basic events .created, .updated, and .deleted. Some models also trigger events specific to their functionality.

You can see an example of a model payload by selecting an event type.

Event type