Skip to main content

Events

Support Team - Swipe One avatar
Written by Support Team - Swipe One
Updated over 2 months ago

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

x-api-key

string

Yes

Your API key for authentication.

Request Parameters

Parameter

Type

Location

Required

Description

workspaceId

string

path

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

contact

object

Yes

Contact details.

contact.id

string

Yes

ID of the contact associated with the event.

type

string

Yes

Event type.

properties

object

No

Additional properties for the event.

createdBy

object

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

400

Invalid input.

401

Unauthorized – API key is missing or invalid.

500

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

x-api-key

string

Yes

Your API key for authentication.

Request Parameters

Parameter

Type

Location

Required

Description

contactId

string

path

Yes

The unique ID of the contact.

page

integer

query

No

Page number for pagination (default: 1).

limit

integer

query

No

Number of events per page (default: 10).

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

404

Contact not found.

401

Unauthorized – API key is missing or invalid.

500

Internal server error.

Example Error Response (404)

{
"status": "fail",
"message": "Contact not found"
}

Notes

  • Supports pagination with page and limit parameters.

  • Events are sorted in descending order by timestamp

Did this answer your question?