Create a webhook
const url = 'https://api.oletapp.com/your-store/v1/webhooks';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"event":"example","target_url":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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 signingsecret. 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 withsecret: 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
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
The event to receive. One of: sale.completed, sale.refunded, customer.created, customer.updated, customer.deleted, product.created, product.updated, product.deleted, inventory.updated.
The https URL that receives each delivery. It must resolve to a public address.
Examplegenerated
{ "event": "example", "target_url": "example"}Responses
Section titled “Responses”Create a webhook
object
object
One of: sale.completed, sale.refunded, customer.created, customer.updated, customer.deleted, product.created, product.updated, product.deleted, inventory.updated.
The signing secret. Present only on the response that creates the webhook, null everywhere else.
Example
{ "data": { "status": "active" }}default
Section titled “default”An error response.
object
object
A machine-readable error code, e.g. VALIDATION_FAILED.
object
A plain-English sentence describing what went wrong.
Example
{ "error": { "code": "UNAUTHORIZED" }}