API v 2.0 (Eng)
UA | US | RU
|
---|
API (Application Programming Interface) is a tool that allows your applications, websites, and CRM to "communicate" and exchange data with the Leeloo.ai platform. With the API, you can retrieve information about your clients, send client data (offers) to a table, integrate online payment or delivery systems, without requiring complex or costly development.
Introduction to API Usage
Headers request
When making requests to Leeloo.AI , you need to use Headers. Add “Request Header” in “Key,” enter X-Leeloo-AuthToken
, and in “Value,” insert your Leeloo.ai API token.
Where to Find the API Token?
The API token can be found in the Leeloo.ai API section on the platform. It is necessary for authenticating requests to the API, confirming that requests come from an authorized user.
Types of Requests
The platform provides various types of requests that can be used for integration with external systems:
GET
: to retrieve data. Requests information from the APIPOST
: to submit data (e.g., registering a new user).PUT
: to update existing data.
Using Variables and Custom Fields
Variables can be created in Content → Variables.
Custom fields can be created in Content → Fields.
You can insert variables and custom fields into the request body if dynamic data transfer is required. For example, to send user or order status information, include variables in the request fields for transmitting individual information.
List of System IDs (Variables) Available on the Platform:
category_id
- the ID of the message template category. Thiscategory_id
is found in the URL when opening the template category in Sales Funnels, Message Templates.
Example - https://app.leeloo.ai/campaigns-templates/category_id
/templatesaccount_id
- the ID from the client card in the Chats section.
Example - https://app.leeloo.ai/chats/unread/account_id
/5e60191da0fd4a000d3998bc/template_id
- the message template ID on the platform, available from the message template created in the template category.
Example - https://app.leeloo.ai/campaigns-templates/category_id
/templates/creator/template_id
person_id
- the communication channel ID found in the client link in Chats.
Example - https://app.leeloo.ai/chats/all/account_id
/person_id
leadgentool_id
- the ID of the Lead Generation Tool (LGT) from your created LGT in the sales funnel. Right-click on it, then “Copy LGT ID”paymentCreditsId
- the payment system ID. You can find it in the platform settings under Payments by clicking “Details” on the connected payment.
Example - https://app.leeloo.ai/settings/integrations/payments/credits/payment-credit/manual/paymentCreditsId
offerId
- the Offer ID taken from the Offers you created in the Sales Funnel section.
Example - https://app.leeloo.ai/campaigns-offers/offerId
/offers/1managerId
- the manager (user) ID added to the platform through the Users section. Click on the created user and copy the ID from the link.
Example - https://app.leeloo.ai/settings/company/users/user/managerId
order_id
- the order ID, which is generated when your offer changes to an order status. This ID can be obtained by performing the “Get Order List” request, which includes information about the order, including the order ID.
Example - "{"data":[{"id":"order_id
","person_id":"person_i
","title":"Курс9","price":20,"currency":"USD","status":"REJECTED","createdAt":"2024-10-03T08:00:02.853Z","updatedAt":"2024-10-03T15:25:49.028Z"},user_id
- the user ID (Subscriber) within the audience. It can be obtained by performing the “Get Platform User List” request, which includes information about the user ID.
Example - "{"data":{"id":"user_id
","name":"Andrew","createdAt":"2024-02-21T12:32:55.085Z","updatedAt":"2024-10-07T06:42:52.631Z"},"status":1}"tunnel_id
- the sales funnel ID. Obtainable by navigating to your sales funnel and copying from the address bar.
Example - https://app.leeloo.ai/tunnels/tunnel_id
/treetunnel_block_id
- the ID of a block in the sales funnel. Obtainable by navigating to your sales funnel, clicking on the block, and copying it from the address bar.
Example - https://app.leeloo.ai/tunnels/tunnel_id
/tree/tunnel_block_id
connection_id
- the communication channel ID. Obtainable by performing a request for user information or specific user information. Example from the “Get Specific Person Information” request:
Example -
{
"account_id": "account_id
",
"connection_id": "connection_id
",
"connection_status": "OK",
"from": "TELEGRAM"
}tag_id
- the Tag ID assigned to users (subscribers). Obtainable by navigating to Platform Settings, CRM Settings, Tags, and clicking “Copy ID” next to the created tag.
In all requests, the date must be specified in UTC-0 time zone.
All requests that involve a Body should be sent in JSON format
Message Templates
Retrieve the List of Message Template Categories
GET https://api.leeloo.ai/api/v2/categories/templates
IMPORTANT: In Headers, add “Request Header.” In “Key,” enter X-Leeloo-AuthToken, and in “Value,” insert your Leeloo.ai API token.
Response
"data": {
"categories": [
{
"id": "5e3bf3fdb70492000f72cd6c",
"name": "Category 1"
},
{
"id": "5e18a2a3ed0b7a000d6c948f",
"name": "Category 2"
}
]
},
"status": 1
}
Retrieve the List of Message Templates Within a Category
GET https://api.leeloo.ai/api/v2/categories/templates/{category_id}
Path Paramscategory_id
(example: 5b3f543bb2737000133d25b0) - Message Template Category ID
This category_id
can be found in the URL when opening the template category in the Sales Funnels, Message Templates section.
Example: https://app.leeloo.ai/campaigns-templates/categoty_id/templates
IMPORTANT: In Headers, add “Request Header.” In “Key,” enter X-Leeloo-AuthToken, and in “Value,” insert your Leeloo.ai API token.
Response
{
"data": {
"templates": [
{
"id": "5e42be758d4fff000cafe6ef",
"message_name": "test template 2"
},
{
"id": "5e42be688d4fff000cafe5cc",
"message_name": "test template 1"
}
]
},
"status": 1
}
Sending a Message Template
POST https://api.leeloo.ai/api/v2/messages/send-template
Request Body(json)account_id
(example: 513f543gb2737020133d25b0) - The communication channel ID can be found in the client card link under the Chats section.
Example: https://app.leeloo.ai/chats/unread/account_id/5e60191da0fd4a000d3998bc/
template_id
(example: 6b3f543bb2737003133d25b4) - The message template ID is available on the platform within the created message template.
{
"account_id": "66fac2b853d5123567d207b7",
"template_id": "65fc3f2656789099e157e817",
"variables": {
"key1": "value1",
"key2": "value2"
}
}
Response
Messages
Retrieve a List of Messages from a Chat by Communication Channel
GET https://api.leeloo.ai/api/v2/communication-channels/{person_id}/chat-messages?limit=2&offset=0
Path Paramsperson_id
(example: 5b3f543bb2737000133d25b0) - The communication channel ID can be found in the client link under the Chats section.
Example: https://app.leeloo.ai/chats/all/66fac2b853d5470e1ed207b6/person_id
Query Paramslimit
- Limit on the Number of Results: It is not recommended to retrieve large amounts of data at once, as this may slow down data export.offset
- Offset (Default 0): Specify how many results to skip.
Response
Sending Messages
POST https://api.leeloo.ai/api/v2/messages/send-message
Request Body(json)account_id
(example: 5b3f543bb2737000133d25b0) - The ID of the communication channel.text
- The text of the message you want to send.
Response
Communication Channels
Retrieve the List of Communication Channels (with external UTM tags)
Query Paramslimit
- Limit on the Number of Results. It is not recommended to retrieve large amounts of data at once, as this may slow down data export.offset
- Specify how many results to skip.filter[last_message][from]
- Filter by Last Message From a Specified Date
filter[last_message][to]
- Filter by Last Message Up to a Specified Date
Response
Retrieve Communication Channel List
GET https://api.leeloo.ai/api/v2/connections
Response
Retrieve Person Information by Communication Channel (retrieve person_id
using the account_id
parameter)
GET https://api.leeloo.ai/api/v2/communication-channels/{account_id}/person
Path Paramsaccount_id
(example: 5b3f543bb2737000133d25b0) - Communication Channel ID
Response
LGT
Create a Traffic Source in LGT
POST https://api.leeloo.ai/api/v2/leadgentools/{leadgentool_id}/create-traffic-source
Path Paramsleadgentool_id
(example: 5b3f543bb2737000133d25b0) - The ID of the lead generation tool
Request Body (json)name
- The name of the traffic sourcedescription
- A description of the traffic source
Response
Orders
Create a Manual Order
POST https://api.leeloo.ai/api/v2/orders
Request Body(json)paymentCreditsId
(example: 5b3f543bb2737000133d25b2) - Payment System ID: Obtainable in the platform settings under the payment systems section.email
- The email address of the personphone
- The phone number of the person.transactionDate
- The date for the transaction to display on the platform, in the format 2020-02-04T11:46:48.803Z
offerId
(example: 5b3f543bb2737000133d25b0) - The ID of the offerisNotifyAccount
- Notify Person About Order Creation: Set to true
or false
depending on whether you want to notify the person.personId
(example: 5b3f543bb2737000133d25b1) - The ID of the person.managerId
(example: 5b3f543bb2737000133d25b0) - Platform User ID Assigned to the Order (Optional): If not specified, the sale will be assigned to "System."
Response
Retrieve Order List
GET https://api.leeloo.ai/api/v2/orders?limit=20&offset=0
Query Paramslimit
- Limit on the Number of Results: It is not recommended to retrieve large amounts of data at once, as this may slow down data export.offset
- Specify how many results to skip
Response
Retrieve Information on a Specific Order
GET https://api.leeloo.ai/api/v2/orders/{order_id}
Path Paramsorder_id
(example: 5b3f543bb2737000133d25b0) - The ID of the specific order
Response
Update Information in a Manual Order
Order Cannot Have Partial Payments
POST https://api.leeloo.ai/api/v2/orders/{order_id}
Path Paramsorder_id
(example: 5b3f543bb2737000133d25b0) - Manual Order ID Without Partial Payments
Request Body (form-data)status
example: 'RESOLVED', (one_of: RESOLVED REJECTED)paymentDate
example: '2018-06-27 07:32',currency
example: 'RUB',price
example: '100' (actual price that you receive from account),userComments
example: 'actual date dont match'
Response
Subscribers
Retrieve List of All Subscribers
Query Paramslimit
- Limit on the Number of Results: It is not recommended to retrieve large amounts of data at once, as this may slow down data export.offset
- Specify how many results to skipfilter[tags]
- filter by specific tags if needed. Optionalfilter[last_message]
{ from: 'js_date', to: 'js_date' } - Mandatory, filter based on the date of the last message.filter[phone]
- filter by phone number if needed. Optional.filter[email]
- filter by email if needed. Optional.
Response
Retrieve Information on a Specific Person
GET https://api.leeloo.ai/api/v2/people/{person_id}?include=contactedUsers,orders
Path Paramsperson_id
(example: 5b3f543bb2737000133d25b0) - The ID of the person
Response
Update Information in a Client Card
PUT https://api.leeloo.ai/api/v2/people/{person_id}
Path Paramsperson_id
(example: 5b3f543bb2737000133d25b0) - The ID of the person
Request Body(json)
Add a Person to the Platform
POST https://api.leeloo.ai/api/v2/people
Request Body (json)
Response
Add SMS Connection to a Person
POST https://api.leeloo.ai/api/v2/people/sms
Request Body(json)
Response
Add a Comment to a Person
PUT https://api.leeloo.ai/api/v2/people/{person_id}/add-comment
Path Paramsperson_id
(example: 5b3f543bb2737000133d25b0) - The ID of the person
Request Body(json)
Response
Add a Call to the Client Card
POST https://api.leeloo.ai/api/v2/calls
Request Body(form-data, all required)user_id
example: ‘5b0d313b307879002915b3cc’from
example: ‘606'to
example: ‘607'date
example: ‘2024-03-22T15:30:17.339Z'account_id
example: '6b0d313b307879002915b3c1’record_link
example: 'https://file-examples.com/storage/2017/11/file_example_MP3_5MG.mp3’ or 'NOT_DEFINED’status
example: 'SUCCESS' (one of: 'TALKING', 'SUCCESS', 'NO_ANSWER', 'CLOSED_BY_SYSTEM')duration
example: '100' (seconds)type
example: INBOUND or OUTBOUND
Response
Tags
Retrieve Tag List
GET https://api.leeloo.ai/api/v2/tags
Response
Remove Tag from a Person
PUT https://api.leeloo.ai/api/v2/people/{person_id}/remove-tag
Path Paramsperson_id
(example: 5b3f543bb2737000133d25b0) - The ID of the person
Request Bodytag_id
- Copy the ID from Settings > Tags (Copy ID)
Response
Add Tag to a Person
PUT https://api.leeloo.ai/api/v2/people/{person_id}/add-tag
Path Paramsperson_id
(example: 5b3f543bb2737000133d25b0) - The ID of the person
Request Body(form-data)tag_id
- Copy the ID from Settings > Tags (Copy ID)
Response
Sales Tunnels
Retrieve Sales Tunnel List
GET https://api.leeloo.ai/api/v2/tunnels?limit=20&offset=0
Query Paramslimit
- Limit on the Number of Results: It is not recommended to retrieve large amounts of data at once, as this may slow down data export.offset
- Specify how many results to skip.
Response
Retrieve Information on a Specific Sales Tunnel
GET https://api.leeloo.ai/api/v2/tunnels/{tunnel_id}?include=leadgentools
Path Paramstunnel_id
(example: 5b3f543bb2737000133d25b0) - tunnel id
Response
Retrieve Statistics for All Sales Tunnels
GET https://api.leeloo.ai/api/v2/tunnels/stats
Response
Retrieve Statistics for a Specific Sales Tunnel
GET https://api.leeloo.ai/api/v2/tunnels/{tunnel_id}/stats
Path Paramstunnel_id
(example: 5b3f543bb2737000133d25b0) - tunnel id
Response
Subscribe to a Sales Tunnel and Specific Tunnel Block
POST https://api.leeloo.ai/api/v2/communication-channels/{account_id}/manual-subscribe
Path Paramsaccount_id
- Communication Channel ID
Request Body (form-data)tunnel_id
(example: 5b3f543bb2737000133d25b0) - tunnel idtunnel_block_id
(example: 5b3f543bb2737000133d25b0) - block id in tunnel
Response
Users
Retrieve Platform User List
GET https://api.leeloo.ai/api/v2/users?limit=20&offset=0
Query Paramslimit
- Limit on the Number of Results. It is not recommended to retrieve large amounts of data at once, as this may slow down data export.offset
- Offset (Default 0): Specify how many results to skip.
Response
Retrieve Information on a Specific Platform User
GET https://api.leeloo.ai/api/v2/users/{user_id}
Path Paramsuser_id
- Platform User ID
Response