Create an Event
Endpoint
POST /workspaces/:workspaceId/events
Description
This endpoint allows creating a new event for a contact in a specified workspace.
Base URL
https://api.swipeone.com/api
Authentication
Method: API Key Authentication
Header:
x-api-key: {your_write_key}
Headers
Header | Type | Required | Description |
|
| Yes | Your API key for authentication. |
Request Parameters
Parameter | Type | Location | Required | Description |
|
|
| Yes | The unique ID of the workspace where the event should be created. |
Request Body
A JSON object containing event details.
Body Parameters
Parameter | Type | Required | Description |
|
| Yes | Contact details. |
|
| Yes | ID of the contact associated with the event. |
|
| Yes | Event type. |
|
| No | Additional properties for the event. |
|
| No | Information about the creator of the event. |
Example Request
curl -X POST "https://api.swipeone.com/api/workspaces/6660175570fbd8a9c22bedfb/events" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contact": {
"id": "6682840d9286aa59ee3d4181"
},
"type": "UserLoggedIn",
"properties": {
"device": "mobile",
"location": "New York"
},
"createdBy": {
"id": "admin123",
"role": "admin"
}
}'
Response
Success Response (202)
When the event is successfully accepted for processing:
{
"status": "success",
"message": "Event accepted for processing"
}
Error Responses
Status Code | Description |
| Invalid input. |
| Unauthorized – API key is missing or invalid. |
| Internal server error. |
Example Error Response (400)
{
"status": "fail",
"message": "Invalid input"
}
Notes
The event type must be predefined and valid within the system.
The
properties
field allows passing additional metadata related to the event.Ensure the
contact.id
provided exists in the system
Retrieve All Events for a Contact
Endpoint
GET /contacts/:contactId/events
Description
This endpoint retrieves all events associated with a specified contact.
Base URL
https://api.swipeone.com/api
Authentication
Method: API Key Authentication
Header:
x-api-key: {your_api_key}
Headers
Header | Type | Required | Description |
|
| Yes | Your API key for authentication. |
Request Parameters
Parameter | Type | Location | Required | Description |
|
|
| Yes | The unique ID of the contact. |
|
|
| No | Page number for pagination (default: |
|
|
| No | Number of events per page (default: |
Example Request
curl -X GET "https://api.swipeone.com/api/contacts/6682840d9286aa59ee3d4181/events?page=1&limit=10" \
-H "x-api-key: YOUR_API_KEY"
Response
Success Response (200)
When events are successfully retrieved:
{
"status": "success",
"data": {
"events": [
{
"type": "email_opened",
"timestamp": "2024-07-01T10:25:17.183Z",
"properties": {
"email_subject": "Welcome to SwipeOne",
"device": "Mobile"
}
},
{
"type": "link_clicked",
"timestamp": "2024-07-02T12:30:10.567Z",
"properties": {
"url": "https://swipeone.com/promo",
"campaign": "July Promo"
}
}
],
"count": 20,
"page": 1
}
}
Error Responses
Status Code | Description |
| Contact not found. |
| Unauthorized – API key is missing or invalid. |
| Internal server error. |
Example Error Response (404)
{
"status": "fail",
"message": "Contact not found"
}
Notes
Supports pagination with
page
andlimit
parameters.Events are sorted in descending order by timestamp