Create or Update a Contact
Endpoint
POST /workspaces/:workspaceId/contacts
Description
This endpoint allows you to create a new contact within a specified workspace.
Base URL
https://api.swipeone.com/api
Authentication
- Method: API Key Authentication 
- Header: - x-api-key: {your_api_key}
Request Parameters
| Parameter | Type | Location | Required | Description | 
| 
 | 
 | 
 | Yes | The unique ID of the workspace where the contact should be created. | 
Request Body
A JSON object containing the contact details.
Body Parameters
| Parameter | Type | Required | Description | 
| 
 | 
 | (Optional if  | First name of the contact. | 
| 
 | 
 | No | Last name of the contact. | 
| 
 | 
 | (Optional if  | Full Name of the contact | 
| 
 | 
 | (Optional if  | Email address of the contact. | 
| 
 | 
 | No | Phone number of the contact. | 
| 
 | 
 | No | Address line 1. | 
| 
 | 
 | No | Address line 2. | 
| 
 | 
 | No | City of the contact. | 
| 
 | 
 | No | State of the contact. | 
| 
 | 
 | No | Country of the contact. | 
| 
 | 
 | No | ZIP code of the contact. | 
| 
 | 
 | No | Contact's date of birth (ISO 8601 format). | 
| 
 | 
 | No | Occupation of the contact. | 
| 
 | 
 | No | Gender of the contact. | 
| 
 | 
 | No | Timezone of the contact. | 
| 
 | 
 | No | Facebook profile URL. | 
| 
 | 
 | No | Twitter profile URL. | 
| 
 | 
 | No | LinkedIn profile URL. | 
| 
 | 
 | No | Department in which the contact works. | 
| 
 | 
 | No | Industry type. | 
| 
 | 
 | No | Size of the team the contact works with. | 
| 
 | 
 | No | Contact's company annual revenue. | 
| 
 | 
 | No | Contact's website URL. | 
Example Request
curl -X POST "https://api.swipeone.com/api/workspaces/6660175570fbd8a9c22bedfb/contacts" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"firstName": "John",
"lastName": "Doe",
"email": "[email protected]",
"phone": "123-456-7890",
"address": {
"line1": "123 Main St",
"line2": "Apt 4B",
"city": "Springfield",
"state": "IL",
"country": "USA",
"zipcode": "62704"
},
"birthday": "1980-01-01T00:00:00.000Z",
"occupation": "Software Engineer",
"gender": "Male",
"timezone": "America/Chicago",
"department": "Engineering",
"teamSize": 100,
"annualRevenue": 1000000,
"website": "https://techcorp.com"
}'
Response
Success Response (201)
When a contact is successfully created:
{
  "status": "success",
  "data": {
    "contact": {
      "_id": "6682840d9286aa59ee3d4181",
      "firstName": "John",
      "lastName": "Doe",
      "fullName": "John Doe",
      "email": "[email protected]",
      "phone": "123-456-7890",
      "createdAt": "2024-07-01T10:25:17.813Z",
      "updatedAt": "2024-07-01T10:25:17.813Z"
    }
  }
}Error Responses
| Status Code | Description | 
| 
 | Bad Request – Invalid input data. | 
| 
 | Unauthorized – API key is missing or invalid. | 
| 
 | Internal server error. | 
Example Error Response (400)
{
  "status": "fail",
  "message": "Invalid input data"
}Headers
| Header | Type | Required | Description | 
| 
 | 
 | Yes | Your API key for authentication. | 
Notes
- At least one of - email,- fullName, or- firstNamemust be provided to create a contact.
- Contacts are associated with a specific workspace. 
- The API validates input data before creating the contact. 
Retrieve All Contacts
Endpoint
GET /workspaces/:workspaceId/contacts
Description
This endpoint retrieves a paginated list of contacts within a specified workspace.
Base URL
https://api.swipeone.com/api
Authentication
- Method: API Key Authentication 
- Header: - x-api-key: {your_api_key}
Request Parameters
| Parameter | Type | Location | Required | Description | 
| 
 | 
 | 
 | Yes | The unique ID of the workspace from which to retrieve contacts. | 
| 
 | 
 | 
 | No | Text to search in contacts (Name or Email). | 
| 
 | 
 | 
 | No | Field to sort by (e.g.,  | 
| 
 | 
 | 
 | No | Sort order:  | 
| 
 | 
 | 
 | No | Token to fetch the next set of results. | 
| 
 | 
 | 
 | No | Token to fetch the previous set of results. | 
| 
 | 
 | 
 | No | Number of contacts to return (default:  | 
Pagination
- The API uses cursor-based pagination with - searchAfterand- searchBeforetokens.
- If - searchAfteris provided, results after the specified token will be retrieved.
- If - searchBeforeis provided, results before the specified token will be retrieved.
- limitspecifies the number of results per request (default is- 20).
Example Request
curl -X GET "https://api.swipeone.com/api/workspaces/6660175570fbd8a9c22bedfb/contacts?limit=10&sort=createdAt&order=1" \
-H "x-api-key: YOUR_API_KEY"
Response
Success Response (200)
When contacts are successfully retrieved:
{
  "status": "success",
  "data": {
    "count": 200,
    "searchAfter": "someToken",
    "searchBefore": "someToken",
    "contacts": [
      {
        "_id": "6682840d9286aa59ee3d4181",
        "firstName": "John",
        "lastName": "Doe",
        "fullName": "John Doe",
        "email": "[email protected]",
        "phone": "123-456-7890",
        "createdAt": "2024-07-01T10:25:17.813Z",
        "updatedAt": "2024-07-01T10:25:17.813Z"
      }
    ]
  }
}Error Responses
| Status Code | Description | 
| 
 | Bad Request – Invalid parameters. | 
| 
 | Unauthorized – API key is missing or invalid. | 
| 
 | Workspace not found. | 
| 
 | Internal server error. | 
Example Error Response (404)
{
  "status": "fail",
  "message": "Workspace not found"
}Headers
| Header | Type | Required | Description | 
| 
 | 
 | Yes | Your API key for authentication. | 
Notes
- This endpoint supports searching by name and email. 
- Results can be sorted and paginated using the - searchAfterand- searchBeforetokensswipeone-backend.
- Ensure the - workspaceIdprovided exists and is valid.
Search Contacts
Endpoint
POST /workspaces/:workspaceId/contacts/search
Description
This endpoint retrieves a filtered, paginated list of contacts from a specified workspace based on the provided search criteria.
Base URL
https://api.swipeone.com/api
Authentication
- Method: API Key Authentication 
- Header: - x-api-key: {your_api_key}
Request Parameters
| Parameter | Type | Location | Required | Description | 
| 
 | 
 | 
 | Yes | The unique ID of the workspace to search contacts in. | 
Request Body
A JSON object containing the search filters and pagination details.
Body Parameters
| Parameter | Type | Required | Description | 
| 
 | 
 | Yes | Filtering criteria using logical conditions ( | 
| 
 | 
 | No | Sorting criteria with fields and order. | 
| 
 | 
 | No | Token to fetch the next set of results. | 
| 
 | 
 | No | Token to fetch the previous set of results. | 
| 
 | 
 | No | Number of contacts to return (default:  | 
| 
 | 
 | No | Text to search in contact attributes like name or email. | 
Example Request
curl -X POST "https://api.swipeone.com/api/workspaces/6660175570fbd8a9c22bedfb/contacts/search" \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filter": {
"type": "and",
"predicates": [
{
"property": "customProperties.subscriptionStatus",
"operator": "is",
"value": "in_trial",
"dataType": "string"
},
{
"property": "gender",
"operator": "is",
"value": "Female",
"dataType": "string"
}
]
},
"limit": 10,
"sort": [
{
"property": "fullName",
"order": "asc"
},
{
"property": "teamSize",
"order": "dsc"
}
],
"searchAfter": "someToken",
"searchBefore": "someToken"
}'
Response
Success Response (200)
When contacts matching the search criteria are found:
{
  "status": "success",
  "data": {
    "count": 200,
    "searchAfter": "someToken",
    "searchBefore": "someToken",
    "contacts": [
      {
        "name": "John Doe",
        "email": "[email protected]"
      }
    ]
  }
}Error Responses
| Status Code | Description | 
| 
 | Bad Request – Invalid input data. | 
| 
 | Unauthorized – API key is missing or invalid. | 
| 
 | Internal server error. | 
Example Error Response (400)
{
  "status": "fail",
  "message": "Invalid input data"
}Headers
| Header | Type | Required | Description | 
| 
 | 
 | Yes | Your API key for authentication. | 
Pagination
- This API uses cursor-based pagination with - searchAfterand- searchBeforetokens.
- Use - searchAfterto get the next set of results.
- Use - searchBeforeto get the previous set of results.
- limitspecifies the number of records per request (default:- 10).
Notes
- Filtering is applied using logical conditions ( - and,- or).
- Supports sorting results based on multiple properties. 
- Ensure - workspaceIdis valid for successful results
Retrieve Contact by ID
Endpoint
GET /contacts/:contactId
Description
This endpoint retrieves details of a specific contact using the provided contact ID.
Base URL
https://api.swipeone.com/api
Authentication
- Method: API Key Authentication 
- Header: - x-api-key: {your_api_key}
Request Parameters
| Parameter | Type | Location | Required | Description | 
| 
 | 
 | 
 | Yes | The unique ID of the contact to retrieve. | 
Headers
| Header | Type | Required | Description | 
| 
 | 
 | Yes | Your API key for authentication. | 
Example Request
curl -X GET "https://api.swipeone.com/api/contacts/6682840d9286aa59ee3d4181" \
-H "x-api-key: YOUR_API_KEY"
Response
Success Response (200)
When the contact is successfully retrieved:
{
  "status": "success",
  "data": {
    "contact": {
      "_id": "6682840d9286aa59ee3d4181",
      "firstName": "John",
      "lastName": "Doe",
      "fullName": "John Doe",
      "email": "[email protected]",
      "phone": "123-456-7890",
      "address": {
        "line1": "123 Main St",
        "line2": "Apt 4B",
        "city": "Springfield",
        "state": "IL",
        "country": "USA",
        "zipcode": "62704"
      },
      "birthday": "1980-01-01T00:00:00.000Z",
      "occupation": "Software Engineer",
      "gender": "Male",
      "timezone": "America/Chicago",
      "company": {
        "id": "5f8f8c44b54764421b7156b1",
        "name": "Tech Corp"
      },
      "socialMediaUrls": {
        "facebook": "https://facebook.com/johndoe",
        "twitter": "https://twitter.com/johndoe",
        "linkedin": "https://linkedin.com/in/johndoe"
      },
      "department": "Engineering",
      "industry": "Technology",
      "teamSize": 100,
      "annualRevenue": 1000000,
      "website": "https://techcorp.com",
      "tags": ["important", "vip"],
      "workspaceId": "6660175570fbd8a9c22bedfb",
      "createdAt": "2024-07-01T10:25:17.813Z",
      "updatedAt": "2024-07-01T10:25:17.813Z"
    }
  }
}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
- Ensure the - contactIdprovided exists in the system.
- The response includes detailed information about the contact, including personal details, company, and engagement summary 

