Flowbytes API (1.0.0)
Our APIs enable you to publish and process events through multiple workflows and action types. This page contains a comprehensive reference for all of our public APIs. For walkthrough documentation please see our main docs site.
To get started, sign up at https://flowbytes.io. This will give you access to the Flowbytes console where you can configure your account and retrieve your credentials needed to authenticate to the API.
To streamline integration we provide client libraries for a number of languages, otherwise you can integrate directly with the API using the HTTP tooling built-in to most modern frameworks.
In order to authenticate with Flowbytes APIs you need to request an OAuth 2.0 Access Token using your Client ID and Secret available from the Flowbytes console.
The following example demonstrates how to do this. To authorize the request, provide your Client ID and Secret
in the Authorization header using the Basic Scheme (base_64_encode(your_client_id:your_client_secret)).
curl --location --request POST 'https://auth.flowbytes.io/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic dGVzdC1hY2Nlc3Mta2V5LWlkOnRlc3QtYWNjZXNzLWtleS1zZWNyZXQ=' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=events:publish'
This will return a Bearer access token in the JSON Web Token (JWT) format which you should use in the Authorization
header of any subsequent Flowbytes API requests:
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"token_type": "bearer",
"expires_in": 3600
}
The access token will be valid for the length of time in seconds indicated by the expires_in field. When it expires, you should request a new one.
If using one of our client libraries, this will be handled automatically for you.
Access Token
Obtain an OAuth 2.0 Access token to authenticate API requests
Request Body schema: application/json
| client_id | string Your OAuth Client ID |
| client_secret | string Your OAuth Client Secret |
| audience | string <uri> Value: "https://api.flowbytes.io" The target API |
| grant_type | string Value: "client_credentials" The OAuth grant type |
Responses
Request samples
- Payload
{- "client_id": "g6gWu46zeP0HH4jkW3i22yJ2shDrNxJ8",
- "client_secret": "S6gozTXzrS42OZ0cmxVJG133mOfuHhSfkIJkcH7FBm-0HyGrVZMLGJtyruTA4CQv",
- "grant_type": "client_credentials"
}Response samples
- 200
{- "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImliVmVSLV...",
- "scope": "events:read events:write",
- "expires_in": 86400,
- "token_type": "Bearer"
}The Events API enables you to publish events to both inline and user workflows, and check the status of triggered workflow actions.
Publish Event
Publish an event
Authorizations:
header Parameters
| Idempotency-Key | string Example: 5c255194-30ec-11ed-a261-0242ac120002 An idempotency key to allow safe retrying without the operation being performed multiple times. The value should be unique for each operation, e.g. a UUID, with the same key being sent on a retry of the same request. |
Request Body schema: application/json
required | object The workflow used to process the event |
| event_type required | string The type of event that occurred |
| event_version | string <semver> The semantic version of the event. Required to activate schema validation. |
required | object The event data that will be provided to the specified workflow actions |
| source | string A reference to the source that generated the event, for example, your product name |
| reference | string Your reference for the event |
| subject | string Your reference for the subject of the event. You can later retrieve the events associated with the subject. |
Responses
Request samples
- Payload
- curl
- C#
{- "workflow": {
- "type": "inline",
- "actions": [
- {
- "type": "webhook",
- "headers": {
- "Authorization": "secret_api_key"
}
}
]
}, - "event_type": "payment_succeeded",
- "event_version": "1.2.1",
- "event_data": {
- "type": "json_object",
- "content": {
- "id": "pay_mbabizu24mvu3mela5njyhpit4",
- "amount_minor": 1099,
- "currency": "EUR",
- "approved": true,
- "reference": "ORD-123456"
}
}, - "source": "payment_gateway",
- "reference": "8f51f0cc-5678-41a2-8f4f-cc342758472a",
- "subject": "pay_mbabizu24mvu3mela5njyhpit4"
}Response samples
- 202
- 422
{- "id": "evt_c7svxlvo2bbuva4f6s3xu4f7wm",
}Get Event
Returns an event's details
Authorizations:
path Parameters
| event_id required | string Example: evt_c7svxlvo2bbuva4f6s3xu4f7wm The unique identifier of the event |
Responses
Response samples
- 200
{- "event_type": "payment_succeeded",
- "event_version": "1.2.1",
- "event_data": {
- "type": "json_object",
- "content": {
- "id": "pay_mbabizu24mvu3mela5njyhpit4",
- "amount_minor": 1099,
- "currency": "EUR",
- "approved": true,
- "reference": "ORD-123456"
}
}, - "source": "payment_gateway",
- "reference": "8f51f0cc-5678-41a2-8f4f-cc342758472a",
- "subject": "pay_mbabizu24mvu3mela5njyhpit4",
- "id": "evt_c7svxlvo2bbuva4f6s3xu4f7wm",
- "status": "processing",
- "actions": [
- {
- "type": "webhook",
- "workflow_id": "wf_b35kpqps3j3etih6iu72wesvai",
- "workflow_action_id": "wfa_l4pm6cadcyierdmmeozuacl7f4",
- "status": "pending",
- "_links": {
}
}
],
}Get Event Action
Returns the details of an action triggered for an event
Authorizations:
path Parameters
| event_id required | string Example: evt_c7svxlvo2bbuva4f6s3xu4f7wm The unique identifier of the event |
| workflow_action_id required | string Example: wfa_l4pm6cadcyierdmmeozuacl7f4 The unique identifier of the workflow action |
Responses
Response samples
- 200
{- "id": "wfa_l4pm6cadcyierdmmeozuacl7f4",
- "workflow_id": "wf_b35kpqps3j3etih6iu72wesvai",
- "event_id": "evt_c7svxlvo2bbuva4f6s3xu4f7wm",
- "type": "webhook",
- "status": "pending",
- "invocations": [
- {
- "id": "ivc_wt2hsl25gafe3htsjl4pt3qa2e",
- "invoked_at": "2019-08-24T14:15:22Z",
- "succeeded": "true,",
- "retry": false,
- "result": {
- "status": "200,",
- "received_at": "2019-08-24T14:15:22Z",
- "duration_ms": 54.6
}
}, - {
- "id": "inv_e5povidz3tsepitj7k7oatedbi",
- "invoked_at": "2019-08-24T14:10:13Z",
- "succeeded": "false,",
- "retry": true,
- "result": {
- "status": "500,",
- "received_at": "2019-08-24T14:15:33Z",
- "duration_ms": 3527.2
}
}
]
}Just like you, we use webhooks (yes we eat our own dogfood) to inform our clients of important activity in their account. This can enable you to automate certain activities, such as informing your users when one of their workflows has been disabled due to destination server issues.
Action Disabled Webhook
The action_disabled event occurs when a workflow action fails to execute, including any retry attempts. A common example of this is when the destination server for a webhook action is unresponsive or unable to handle the webhook accordingly.
It may be possible to re-enable the action immediately. To verify this, look for the presence of the enable link.
Request Body schema: application/json
| id required | string The unique identifier of the event |
| type required | string The type of event |
| occurred_at required | string <date-time> The date & time that the event occurred |
required | object The event data |
Responses
Request samples
- Payload
{- "id": "evt_aglyryuvkjoupf6fitq2rfmpvu",
- "type": "action_disabled",
- "occurred_at": "2019-08-24T14:15:22Z",
- "data": {
- "workflow_action_id": "wfa_l4pm6cadcyierdmmeozuacl7f4",
- "workflow_id": "wf_b35kpqps3j3etih6iu72wesvai",
- "user_id": "usr_tubbrr4odyiuvb4idu2eodzgku",
- "_links": {
}
}
}