Write data to Third-party Apps
In this, you’ll get to know how you can send data from your app to other apps.
You can send data from your apps to other apps by using Cobalt Events.
An event model contains name of the event and the trigger payload. The trigger payload contains sample data schema that can be used as data variables and are used inside a workflow as placeholders while defining the workflow.
To learn more about Cobalt Events, you can refer to our guide here.
Create Event
Follow these steps to create an Event in Cobalt:
- Create Event : Navigate to
Developer
in Cobalt >Events
> Click onNew Event
> Select aModel
> Update the sample Payload to your requirements > Click onCreate Event
.
It is expected that you pass on the data as the Sample Payload while you are triggering this event. This is because, the properties defined in the sample payload can be used as trigger variables inside a workflow.
Trigger an Event
You can trigger an event that was created in Cobalt by using the Trigger Event API.
- Request : Make a POST request to the
/event/:slug
endpoint.linked_account_id
is a mandatory field to be passed while making the request.
Param | Required | Type | Description |
---|---|---|---|
linked_account_id | Mandatory | String | Unique customer identifier |
event | Mandatory | String | Name of the event |
payload | Optional | Object | Event payload with user data required for the workflow. |
- Response : On a successful request, you will get a message that the event was triggered successfully.
- Handle Errors : If the
/event/:slug
endpoint returns a 400 error, your server-side code should handle it gracefully. The error is returned if you provided the wrong name of the event.
Checkpoint
You have now created an event in Cobalt and can send data from your app to other third party apps or integrations enabled in Cobalt.