Create an Event

Last updated 9 months ago

Create an Event

post
Create an Event

https://api.moltin.com
/v2/integrations
Request
Response
Headers
Authorization
required
string
The Bearer token to grant access to the API
Body Parameters
configuration
required
object
The webhook configuration object
observes
required
array
An array of events you want to observe
enabled
optional
boolean
Should the event trigger or not. Default:false
integration_type
required
string
webhook
description
required
string
A description for the event
name
required
string
The name of the event
type
required
string
Represents the type of object
201: Created
{
"data": {
"id": "8cb9e689-ede7-4f6d-b61a-6aa970d572dd",
"type": "integration",
"integration_type": "webhook",
"name": "Order shipping notification",
"description": "Send a shipping notification via email with discount code.",
"enabled": true,
"configuration": {
"url": "https://yourwebsite.com/order-created-notification"
},
"observes": [
"order.fulfilled"
],
"links": {
"self": "https://api.moltin.com/v2/integrations/8cb9e689-ede7-4f6d-b61a-6aa970d572dd"
},
"meta": {
"timestamps": {
"created_at": "2018-04-30T09:35:32.202Z",
"updated_at": "2018-04-30T09:35:32.202Z"
}
}
}
}
cURL
curl -X POST https://api.moltin.com/v2/integrations \
-H "Authorization: Bearer: XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data": {
"type": "integration",
"name": "Order shipping notification",
"description": "Send a shipping notification via email with discount code.",
"enabled": true,
"observes": [
"order.fulfilled"
],
"integration_type": "webhook",
"configuration": {
"url": "https://yourwebsite.com/order-created-notification"
}
}
}'

Configuration Object

So that we can properly fire a webhook, you will need to provide some configuration when creating a new event.

Configuring a webhook

Webhooks are delivered using POST to the configured url. You may specify a secret_key which we will forward __X-MOLTIN-SECRET-KEY along with the request as a header.

X-MOLTIN-INTEGRATION-TRIGGER will also be added to the request headers, this allows you to process several events at the same url. This will be in the format of an observable event key.

The webhook configuration object has the following structure.

Summary
JSON

Attribute

Type

Description

url

string

A required URL the observable event will fire.

secret_key

string

A optional header. Useful to authenticate the response came from Moltin. Will be sent as X-MOLTIN-SECRET-KEY

{
"url": "https://yourwebsite.com/order-created-notification", // Required
"secret_key": "secret_key_to_validate_on_your_endpoint" // Optional
}