Ocelot API (1.0.0-beta2)
Download OpenAPI specification:Download
The Ocelot API is a RESTful API that provides endpoints for contact and contact list management.
To get started with the Ocelot API, you need to authenticate. The base API endpoint is https://ai.ocelotbot.com/api/v1.
Visit the published Contact List endpoints list for more details and working code examples.
The Contact List is a technical entity which groups Contacts by technical concepts and applies constrains.
The concepts are:
Each Contact List has a schema which defins the posible fields a Contact can have during creation. An example of a field is:
{ type: PhoneNumber, // The type of the field accepted by endpoint name: 'Phone_Number', // The name of the field used as a variable value in templates displayName: 'Phone Number', // The display name required: true, // The flag enables constrain on the value unique: true, // The flag enables constrain on the value },
The schema consists of default and user provided parts.
Default schema is
// Contact List Default schema [ { type: PhoneNumber, name: 'Phone_Number', displayName: 'Phone Number', required: true, unique: true, }, { type: Email, name: 'Email_Address', displayName: 'Email Address', required: false, unique: true, }, { type: FirstName, name: 'First_Name', displayName: 'First Name', required: false, unique: false, }, { type: LastName, name: 'Last_Name', displayName: 'Last Name', required: false, unique: false, }, ]
User provided part can be set while creating Contact List via providing additionalContactFields. An example is: ```javascript { type: Text, name: 'Address', displayName: 'Address, required: false, unique: false, }
Creates a contact list
Authorizations:
Request Body schema: application/jsonrequired
name required | string (ContactList.name) |
tags | Array of strings (ContactList.tag) [ items <= 50 characters ] |
object (ContactList.meta) Information about the contact list entity's metadata. It is not limited to just the | |
Array of objects (ContactSchemaField) |
Responses
Request samples
- Payload
- JavaScript
{- "name": "University N1",
- "tags": [
- "Summer school"
], - "meta": {
- "source": "ocelot",
- "externalId": 0
}, - "additionalContactFields": [
- {
- "type": "Text",
- "name": "Address",
- "displayName": "Address",
- "required": false,
- "unique": false
}
]
}
Response samples
- 201
- 400
- 401
- 413
{- "id": "507f1f77bcf86cd799439011",
- "name": "University N1",
- "tags": [
- "Summer school"
], - "meta": {
- "source": "ocelot",
- "externalId": 0
}, - "chatbotId": "964783cd-c648-4628-8262-55dac3831d8f",
- "created": "2019-08-24T14:15:22Z",
- "updated": "2019-08-24T14:15:22Z",
- "userId": "public_api"
}
Replace contact list (lookup by name)
Reset and replace contact list data and also remove all contacts in the contact list
Authorizations:
Request Body schema: application/jsonrequired
name required | string (ContactList.name) |
tags | Array of strings (ContactList.tag) [ items <= 50 characters ] |
object (ContactList.meta) Information about the contact list entity's metadata. It is not limited to just the | |
Array of objects (ContactSchemaField) |
Responses
Request samples
- Payload
- JavaScript
{- "name": "University N1",
- "tags": [
- "Summer school"
], - "meta": {
- "source": "ocelot",
- "externalId": 0
}, - "additionalContactFields": [
- {
- "type": "Text",
- "name": "Address",
- "displayName": "Address",
- "required": false,
- "unique": false
}
]
}
Response samples
- 200
- 400
- 401
- 413
{- "id": "507f1f77bcf86cd799439011",
- "name": "University N1",
- "tags": [
- "Summer school"
], - "meta": {
- "source": "ocelot",
- "externalId": 0
}, - "chatbotId": "964783cd-c648-4628-8262-55dac3831d8f",
- "created": "2019-08-24T14:15:22Z",
- "updated": "2019-08-24T14:15:22Z",
- "userId": "public_api"
}
Reads the contact list
Authorizations:
path Parameters
contactListId required | string The contact list ID |
Responses
Request samples
- JavaScript
// Replace with the actual contact list ID const contactListId = "your-contact-list-id"; // Your credentials // To find correct credentials visit Basic Authentication Flow page. const username = "Your chatbot UUID" const password = "Your ocelot API key" // Endpoint URL const apiUrl = "https://ai.ocelotbot.com/api/v1/contact-list"; // Encoded credentials const base64_encoded_credentials = btoa(`${username}:${password}`); // Fetch options const options = { method: "GET", headers: { "Content-Type": "application/json", Authorization: `Basic ${base64_encoded_credentials}` } }; fetch(`${apiUrl}/${contactListId}`, options) .then(response => { if (response.ok) { return response.json(); } else if (response.status === 401) { throw new Error('Unauthorized'); } else if (response.status === 404) { throw new Error('Contact list not found'); } else { throw new Error('Error occurred'); } }) .then(data => { // Handle the retrieved contact list data console.log(data); }) .catch(error => { // Handle any errors that occurred during the request console.error(error); });
Response samples
- 200
- 401
- 404
{- "id": "507f1f77bcf86cd799439011",
- "name": "University N1",
- "tags": [
- "Summer school"
], - "meta": {
- "source": "ocelot",
- "externalId": 0
}, - "chatbotId": "964783cd-c648-4628-8262-55dac3831d8f",
- "created": "2019-08-24T14:15:22Z",
- "updated": "2019-08-24T14:15:22Z",
- "userId": "public_api"
}
Replace contact list
Reset and replace contact list data and also remove all contacts in the contact list
Authorizations:
path Parameters
contactListId required | string The contact list ID |
Request Body schema: application/jsonrequired
name required | string (ContactList.name) |
tags | Array of strings (ContactList.tag) [ items <= 50 characters ] |
object (ContactList.meta) Information about the contact list entity's metadata. It is not limited to just the | |
Array of objects (ContactSchemaField) |
Responses
Request samples
- Payload
- JavaScript
{- "name": "University N1",
- "tags": [
- "Summer school"
], - "meta": {
- "source": "ocelot",
- "externalId": 0
}, - "additionalContactFields": [
- {
- "type": "Text",
- "name": "Address",
- "displayName": "Address",
- "required": false,
- "unique": false
}
]
}
Response samples
- 200
- 400
- 401
- 413
{- "id": "507f1f77bcf86cd799439011",
- "name": "University N1",
- "tags": [
- "Summer school"
], - "meta": {
- "source": "ocelot",
- "externalId": 0
}, - "chatbotId": "964783cd-c648-4628-8262-55dac3831d8f",
- "created": "2019-08-24T14:15:22Z",
- "updated": "2019-08-24T14:15:22Z",
- "userId": "public_api"
}
Deletes the contact list
Authorizations:
path Parameters
contactListId required | string The contact list ID |
Responses
Request samples
- JavaScript
// Replace with the actual contact list ID const contactListId = "your-contact-list-id"; // Your credentials // To find correct credentials visit Basic Authentication Flow page. const username = "Your chatbot UUID" const password = "Your ocelot API key" // Endpoint URL const apiUrl = "https://ai.ocelotbot.com/api/v1/contact-list"; // Encoded credentials const base64_encoded_credentials = btoa(`${username}:${password}`); // Fetch options const options = { method: "DELETE", headers: { "Content-Type": "application/json", Authorization: `Basic ${base64_encoded_credentials}` } }; fetch(`${apiUrl}/${contactListId}`, options) .then(response => { if (response.ok) { console.log('Contact list deleted successfully'); } else if (response.status === 401) { throw new Error('Unauthorized'); } else if (response.status === 404) { throw new Error('Contact list not found'); } else { throw new Error('Error occurred'); } }) .catch(error => { // Handle any errors that occurred during the request console.error(error); });
Response samples
- 401
- 404
{- "statusCode": 401,
- "message": "Invalid authentication credentials",
- "error": "Unauthorized"
}
Creates contacts in the contact lists
Authorizations:
path Parameters
contactListId required | string The contact list ID |
Request Body schema: application/jsonrequired
Array of objects (ContactInput) The list of contact objects to create. | |||||||||||
Array
|
Responses
Request samples
- Payload
- JavaScript
{- "contacts": [
- {
- "fields": [
- {
- "type": "PhoneNumber",
- "name": "Phone_Number",
- "value": "123-456-7890"
}, - {
- "type": "Email",
- "name": "Email_Address",
- "value": "john.smith@ocelot.ai"
}, - {
- "type": "FirstName",
- "name": "First_Name",
- "value": "John"
}, - {
- "type": "LastName",
- "name": "Last_Name",
- "value": "Smith"
}
]
}
]
}
Response samples
- 201
- 400
- 401
- 404
- 413
[- {
- "errors": [
- "Phone Number 123-456-7890 is not unique."
], - "results": {
- "total": 0,
- "rejected": 0,
- "rejectedData": [
- {
- "fields": [
- {
- "type": "PhoneNumber",
- "name": "Phone_Number",
- "value": "123-456-7890"
}
], - "error": "Phone Number 123-456-7890 is not unique."
}
]
}
}
]
Lists contact list contacts
Authorizations:
path Parameters
contactListId required | string The contact list ID |
query Parameters
order | string (Order) Enum: "ASC" "DESC" The order criteria of the result set |
orderBy | string (OrderBy) The field to order result set by |
limit | integer (Limit) Default: 50 The numbers of items |
skip | integer (Skip) Default: 0 The number of items to skip before starting to collect the result set |
Responses
Request samples
- JavaScript
// Replace with the actual contact list ID const contactListId = "your-contact-list-id"; // Your credentials // To find correct credentials visit Basic Authentication Flow page. const username = "Your chatbot UUID" const password = "Your ocelot API key" // Endpoint URL const apiUrl = "https://ai.ocelotbot.com/api/v1/contact-list"; // Encoded credentials const base64_encoded_credentials = btoa(`${username}:${password}`); // Fetch options const options = { method: "GET", headers: { "Content-Type": "application/json", Authorization: `Basic ${base64_encoded_credentials}` }, }; // Query params const query = { limit: 100, skip: 0 } fetch(`${apiUrl}/${contactListId}/contacts?${new URLSearchParams(query)}`, options) .then((response) => { if (response.ok) { return response.json(); } else if (response.status === 401) { throw new Error('Unauthorized'); } else if (response.status === 404) { throw new Error('Contact list not found'); } else { throw new Error('Error occurred'); } }) .then((data) => { // Handle the retrieved contact list data console.log(data); }) .catch((error) => { // Handle any errors that occurred during the request console.error(error); });
Response samples
- 200
- 401
- 404
{- "results": {
- "limit": 50,
- "skip": 0,
- "total": 123,
- "data": [
- {
- "fields": [
- {
- "type": "PhoneNumber",
- "name": "Phone_Number",
- "value": "123-456-7890"
}, - {
- "type": "Email",
- "name": "Email_Address",
- "value": "john.smith@ocelot.ai"
}, - {
- "type": "FirstName",
- "name": "First_Name",
- "value": "John"
}, - {
- "type": "LastName",
- "name": "Last_Name",
- "value": "Smith"
}
], - "active": true,
- "created": "2019-08-24T14:15:22Z"
}
]
}
}