Skip to main content

Tasks

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

Create a Task

Endpoint

POST /workspaces/:workspaceId/tasks

Description

This endpoint allows creating a new task in a specified workspace.

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

workspaceId

string

path

Yes

The unique ID of the workspace where the task should be created.

Request Body

A JSON object containing the task details.

Body Parameters

Parameter

Type

Required

Description

name

string

Yes

Name of the task.

assignedTo

string

No

The user assigned to the task.

dueDate

string

No

Due date of the task (ISO 8601 format).

reminder

string

No

Reminder date for the task (ISO 8601 format).

contactId

string

No

The contact associated with the task.

Example Request

curl -X POST "https://api.swipeone.com/api/workspaces/6660175570fbd8a9c22bedfb/tasks" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Follow up with John Doe",
"assignedTo": "user123",
"dueDate": "2024-07-10T12:00:00Z",
"reminder": "2024-07-09T12:00:00Z",
"contactId": "6682840d9286aa59ee3d4181"
}'

Response

Success Response (201)

{
"status": "success",
"data": {
"task": {
"_id": "669b2c93efb8b213a7c72a8e",
"name": "Follow up with John Doe",
"assignedTo": "user123",
"dueDate": "2024-07-10T12:00:00Z",
"reminder": "2024-07-09T12:00:00Z",
"contactId": "6682840d9286aa59ee3d4181",
"workspaceId": "6660175570fbd8a9c22bedfb",
"createdAt": "2024-07-01T10:25:17.813Z",
"updatedAt": "2024-07-01T10:25:17.813Z"
}
}
}

Error Responses

Status Code

Description

400

Invalid input.

401

Unauthorized – API key is missing or invalid.

500

Internal server error.


Retrieve Tasks for a Contact

Endpoint

GET /workspaces/:workspaceId/contacts/:contactId/tasks

Description

This endpoint retrieves a list of tasks associated with a specific contact.

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 tasks per page (default: 10).

Example Request

curl -X GET "https://api.swipeone.com/api//workspaces/6660175570fbd8a9c22bedfb/contacts/6682840d9286aa59ee3d4181/tasks?page=1&limit=10" \
-H "x-api-key: YOUR_API_KEY"

Response

Success Response (200)

{
"status": "success",
"data": {
"tasks": [
{
"_id": "669b2c93efb8b213a7c72a8e",
"name": "Follow up with John Doe",
"assignedTo": "user123",
"dueDate": "2024-07-10T12:00:00Z",
"reminder": "2024-07-09T12:00:00Z",
"contactId": "6682840d9286aa59ee3d4181"
}
],
"total": 20,
"page": 1
}
}

Retrieve Task by ID

Endpoint

GET /tasks/:taskId

Description

Retrieves a specific task using its ID.

Example Request

curl -X GET "https://api.swipeone.com/api/tasks/669b2c93efb8b213a7c72a8e" \
-H "x-api-key: YOUR_API_KEY"

Response

Success Response (200)

{
"status": "success",
"data": {
"task": {
"_id": "669b2c93efb8b213a7c72a8e",
"name": "Follow up with John Doe",
"assignedTo": "user123",
"dueDate": "2024-07-10T12:00:00Z",
"reminder": "2024-07-09T12:00:00Z",
"contactId": "6682840d9286aa59ee3d4181"
}
}
}

Update a Task

Endpoint

PATCH /tasks/:taskId

Description

Update a task using its ID.

Request Body

Parameter

Type

Required

Description

name

string

No

Updated name of the task.

assignedTo

string

No

Updated assigned user.

dueDate

string

No

Updated due date (ISO 8601 format).

reminder

string

No

Updated reminder date (ISO 8601 format).

status

string

No

Task status (not_started, in_progress, completed).

Example Request

curl -X PATCH "https://api.swipeone.com/api/tasks/669b2c93efb8b213a7c72a8e" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Updated Task Name",
"status": "in_progress"
}'

Response

Success Response (200)

{
"status": "success",
"data": {
"task": {
"_id": "669b2c93efb8b213a7c72a8e",
"name": "Updated Task Name",
"assignedTo": "user123",
"status": "in_progress"
"dueDate": "2024-07-10T12:00:00Z",
"reminder": "2024-07-09T12:00:00Z",
"contactId": "6682840d9286aa59ee3d4181"
}
}
}

Retrieve All Tasks (Paginated)

Endpoint

GET /workspaces/:workspaceId/tasks

Description

This endpoint retrieves a paginated list of all tasks within a specified workspace.

Example Request

curl -X GET "https://api.swipeone.com/api/workspaces/6660175570fbd8a9c22bedfb/tasks?page=1&limit=10" \
-H "x-api-key: YOUR_API_KEY"

Response

Success Response (200)

When tasks are successfully retrieved:

{
"status": "success",
"data": {
"total": 50,
"page": 1,
"limit": 10,
"tasks": [
{
"_id": "669b2c93efb8b213a7c72a8e",
"name": "Follow up with John Doe",
"assignedTo": "user123",
"dueDate": "2024-07-10T12:00:00Z",
"reminder": "2024-07-09T12:00:00Z",
"status": "in_progress",
"contactId": "6682840d9286aa59ee3d4181",
"workspaceId": "6660175570fbd8a9c22bedfb",
"createdAt": "2024-07-01T10:25:17.813Z",
"updatedAt": "2024-07-01T10:25:17.813Z"
}
]
}
}

Error Responses

Status Code

Description

400

Invalid input parameters.

401

Unauthorized – API key is missing or invalid.

404

Workspace not found.

500

Internal server error.

Example Error Response (400)

{
"status": "fail",
"message": "Invalid input parameters"
}

Notes

  • Supports pagination using page and limit parameters.

  • Optional filters allow retrieving tasks based on status and assignedTo.

  • Ensure that the workspaceId provided exists in the system.

Did this answer your question?