Webhook

Retrieve and manage all the webhooks from this shop. Webhooks allow you to subscribe to certain events and be notified when they occur. To learn more about how webhooks work see the Webhook tutorial.

Example object

{
    "webhook": {
        "id": 64674,
        "createdAt": "2019-08-07T19:23:09+00:00",
        "updatedAt": "2019-08-07T19:23:09+00:00",
        "isActive": true,
        "itemGroup": "products",
        "itemAction": "*",
        "language": {
            "id": 18,
            "code": "us",
            "locale": "en_US",
            "title": "English (US)"
        },
        "format": "xml",
        "address": "https://requestb.in/12345"
    }
}

Properties

id The unique numeric identifier for the webhook. {“id”: {id}}
createdAt The date and time when the webhook was created. (format: ISO-8601){“createdAt”: “2019-08-07T19:23:09+00:00”}
updatedAt The date and time when the webhook was last updated. (format: ISO-8601){“updatedAt”: “2019-08-07T19:23:09+00:00”}
isActive If the webhook is active or not. (format: boolean){“isActive”: “true|false”}
itemGroup The item group. Available groups: customers, orders, invoices, shipments, products, variants, quotes, reviews, returns, subscriptions. {“itemGroup”: “customers”}
itemAction The item action. {“itemAction”: “created|updated|deleted”}
language Language object. {“language”:{“id”: 18,
“code”: “us”,
“locale”: “en_US”,
“title”: “English (US)”
}
}
format Format of the webhook payload. {“format”: “json|xml”}
address Webhook URL that we’ll call when the event is triggered. {“address”: “https://requestb.in/12345”}

GET All webhooks

Retrieve a list of all webhook objects from this shop.

Definition

GET /webhooks.json

Example request

curl https://api.shoplightspeed.com/en/webhooks.json \
  -u {key}:{secret}
<?php $api->webhooks->get();

Example response

{
    "webhooks": [
        {
            "id": 64674,
            "createdAt": "2019-08-07T19:23:09+00:00",
            "updatedAt": "2019-08-07T19:23:09+00:00",
            "isActive": true,
            "itemGroup": "products",
            "itemAction": "*",
            "language": {
                "id": 18,
                "code": "us",
                "locale": "en_US",
                "title": "English (US)"
            },
            "format": "xml",
            "address": "https://requestb.in/12345"
        }
    ]
}

Arguments

  No arguments available.

Filters

limit Number of results. {(default: 50) (maximum: 250)}
page Page to show. {(default: 1)}
since_id Restrict results to after the specified ID. {(default: 0)}
created_at_min Show webhooks created after date. {(format: YYYY-MM-DD HH:MM:SS)}
created_at_max Show webhooks created before date. {(format: YYYY-MM-DD HH:MM:SS)}
updated_at_min Show webhooks last updated after date. {(format: YYYY-MM-DD HH:MM:SS)}
updated_at_max Show webhooks last updated before date. {(format: YYYY-MM-DD HH:MM:SS)}
fields Comma-separated list of fields to include in the response. {(format: id,createdAt)}

GET Number of webhooks

Retrieve the total number of webhook objects from this shop.

Definition

GET /webhooks/count.json

Example request

curl https://api.shoplightspeed.com/en/webhooks/count.json \
  -u {key}:{secret}
<?php $api->webhooks->count();

Example response

{
  "count": 1
}

Arguments

  No arguments available.

Filters

limit Number of results. {(default: 50) (maximum: 250)}
page Page to show. {(default: 1)}
since_id Restrict results to after the specified ID. {(default: 0)}
created_at_min Show webhooks created after date. {(format: YYYY-MM-DD HH:MM:SS)}
created_at_max Show webhooks created before date. {(format: YYYY-MM-DD HH:MM:SS)}
updated_at_min Show webhooks last updated after date. {(format: YYYY-MM-DD HH:MM:SS)}
updated_at_max Show webhooks last updated before date. {(format: YYYY-MM-DD HH:MM:SS)}
fields Comma-separated list of fields to include in the response. {(format: id,createdAt)}

GET Retrieve a webhook

Retrieve a single webhook based on the unique identifier.

Definition

GET /webhooks/{webhook_id}.json

Example request

curl https://api.shoplightspeed.com/en/webhooks/{webhook_id}.json \
  -u {key}:{secret}
<?php $api->webhooks->get($webhook_id);

Example response

{
    "webhook": {
        "id": 64674,
        "createdAt": "2019-08-07T19:23:09+00:00",
        "updatedAt": "2019-08-07T19:23:09+00:00",
        "isActive": true,
        "itemGroup": "products",
        "itemAction": "*",
        "language": {
            "id": 18,
            "code": "us",
            "locale": "en_US",
            "title": "English (US)"
        },
        "format": "xml",
        "address": "https://requestb.in/12345"
    }
}

Arguments

id The unique numeric identifier for the webhook. {“id”: {id}}

POST Create a webhook

Create a new webhook based on the given parameters.

Definition

POST /webhooks.json

Example request

curl -X POST https://api.shoplightspeed.com/en/webhooks.json \
  -u {key}:{secret} \
  -d webhook[isActive]="true" \
  -d webhook[itemGroup]="products" \
  -d webhook[itemAction]="*" \
  -d webhook[language]="us" \
  -d webhook[format]="xml" \
  -d webhook[address]="https://requestb.in/"12345"
<?php $api->webhooks->create([
    "isActive"    => "true",
    "itemGroup"   => "products",
    "itemAction"  => "*",
    "language"    => "us",
    "format"      => "xml",
    "address"     => "https://requestb.in/12345"
]);

Example Json payload

{
  "webhook": {
    "isActive": true,
    "itemGroup": "products",
    "itemAction": "*",
    "language": "us",
    "format": "xml",
    "address": "https://requestb.in/12345"
  }
}

Example response

{
    "webhook": {
        "id": 64674,
        "createdAt": "2019-08-07T19:23:09+00:00",
        "updatedAt": "2019-08-07T19:23:09+00:00",
        "isActive": true,
        "itemGroup": "products",
        "itemAction": "*",
        "language": {
            "id": 18,
            "code": "us",
            "locale": "en_US",
            "title": "English (US)"
        },
        "format": "xml",
        "address": "https://requestb.in/12345"
    }
}

Arguments

isActive If the webhook is active or not. (format: boolean){“isActive”: “true|false”}
itemGroup The item group. Available groups: customers, orders, invoices, shipments, products, variants, quotes, reviews, returns, subscriptions. {“itemGroup”: “customers”}
itemAction The item action. {“itemAction”: “created|updated|deleted”}
language Two letter code representing the language. (format: ISO 639-1){“language”: “us”}
format Format of the webhook payload. {“format”: “json|xml”}
address Webhook URL that we’ll call when the event is triggered. {“address”: “https://requestb.in/12345”}

PUT Update a webhook

Update an existing webhook based on the given parameters.

Definition

PUT /webhooks/{webhook_id}.json

Example request

curl -X PUT https://api.shoplightspeed.com/en/webhooks/{webhook_id}.json \
  -u {key}:{secret} \
  -d webhook[isActive]=true \
  -d webhook[itemGroup]="products" \
  -d webhook[itemAction]="*" \
  -d webhook[format]="xml" \
  -d webhook[address]="https://requestb.in/12345"
<?php $api->webhooks->update($webhook_id, [
    "isActive"    => true,
    "itemGroup"   => "products",
    "itemAction"  => "*",
    "format"      => "xml",
    "address"     => "https://requestb.in/12345"
]);

Example Json payload

{
  "webhook": {
    "isActive": true,
    "itemGroup": "products",
    "itemAction": "*",
    "format": "xml",
    "address": "https://requestb.in/12345"
  }
}

Example response

{
    "webhook": {
        "id": 64674,
        "createdAt": "2019-08-07T19:23:09+00:00",
        "updatedAt": "2019-08-07T19:23:09+00:00",
        "isActive": true,
        "itemGroup": "products",
        "itemAction": "*",
        "language": {
            "id": 18,
            "code": "us",
            "locale": "en_US",
            "title": "English (US)"
        },
        "format": "xml",
        "address": "https://requestb.in/12345"
    }
}

Arguments

isActive If the webhook is active or not. (format: boolean){“isActive”: “true|false”}
itemGroup The item group. Available groups: customers, orders, invoices, shipments, products, variants, quotes, reviews, returns, subscriptions. {“itemGroup”: “customers”}
itemAction The item action. {“itemAction”: “created|updated|deleted”}
format Format of the webhook payload. {“format”: “json|xml”}
address Webhook URL that we’ll call when the event is triggered. {“address”: “https://requestb.in/17hcl441”}

DELETE Delete a webhook

Delete an existing webhook based on the unique identifier.

Definition

DELETE /webhooks/{webhook_id}.json

Example request

curl -X DELETE https://api.shoplightspeed.com/en/webhooks/{webhook_id}.json \
  -u {key}:{secret}
<?php $api->webhooks->delete($webhook_id);

Example response

HTTP/1.1 204 No Content

Arguments

id The unique numeric identifier for the webhook. {“id”: {id}}