Skip to content

Create a webhook

POST
/webhooks
curl --request POST \
--url https://api.oletapp.com/your-store/v1/webhooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "event": "example", "target_url": "example" }'

Subscribes a URL to one event. The credential needs the read scope of the event’s resource: sales:read for sale events, customers:read for customer events, catalog:read for product events and inventory:read for inventory events.

  • 201: the webhook was created. The response carries the signing secret. It is shown once and cannot be retrieved again.
  • 200: this credential already has a webhook for the same event and URL. The existing webhook is returned with secret: null.
  • 403 INSUFFICIENT_SCOPE: the credential lacks the read scope for the event.
  • 422 VALIDATION_FAILED: the event is unknown.
  • 422 UNPROCESSABLE: the URL is not https, is longer than 2000 characters, contains credentials, or does not resolve to a public address; or the credential already has 50 webhooks.

Each credential can have 50 webhooks. Deliveries follow the Webhooks guide.

Requires scope: any

Media typeapplication/json
object
event
required

The event to receive. One of: sale.completed, sale.refunded, customer.created, customer.updated, customer.deleted, product.created, product.updated, product.deleted, inventory.updated.

string
target_url
required

The https URL that receives each delivery. It must resolve to a public address.

string
<= 2000 characters
Examplegenerated
{
"event": "example",
"target_url": "example"
}

Create a webhook

Media typeapplication/json
object
data
required
object
created_at
required
string format: date-time
/^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$/
event
required

One of: sale.completed, sale.refunded, customer.created, customer.updated, customer.deleted, product.created, product.updated, product.deleted, inventory.updated.

string
id
required
string format: uuid
/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/
secret
required

The signing secret. Present only on the response that creates the webhook, null everywhere else.

string | null
status
required
string
Allowed values: active disabled
target_url
required
string
Example
{
"data": {
"status": "active"
}
}

An error response.

Media typeapplication/json
object
error
required
object
code
required

A machine-readable error code, e.g. VALIDATION_FAILED.

string
Allowed values: UNAUTHORIZED PLAN_REQUIRED INSUFFICIENT_SCOPE NOT_FOUND VALIDATION_FAILED CONFLICT STALE_VERSION RATE_LIMITED IDEMPOTENCY_KEY_REUSED IDEMPOTENCY_IN_PROGRESS IMAGE_FETCH_FAILED UNPROCESSABLE INTERNAL RETAILER_CANCELLED RETAILER_SUSPENDED RETAILER_NOT_FOUND TRIAL_DECISION_REQUIRED PLAN_USERS_EXCEEDED RETAILER_PAUSED PRODUCT_LIMIT_REACHED NOT_STOCK_TRACKED REASON_DIRECTION_MISMATCH REASON_NOT_ALLOWED INSUFFICIENT_STOCK OUTLET_DELETED
fields
Array<object>
object
field
required
string
message
required
string
message
required

A plain-English sentence describing what went wrong.

string
Example
{
"error": {
"code": "UNAUTHORIZED"
}
}