1CRM REST API
General
Welcome to 1CRM REST API documentation!
1CRM provides API (Application Programming Interface) for integrating with third-party applications such as accounting, ERP, e-commerce, self-service portals and others. With the 1CRM API, you can extract data in JSON format and develop new applications or integrate with your existing applications.
Connecting to 1CRM API
1CRM API calls are performed as HTTP requests to /1crm/api.php
, with endpoint
appended to it. Note that endpoints listed in this documentation do not
include the base URI /1crm/api.php
. For example, if the documentation says that
to retrieve accounts list, one would send an HTTP GET request to /data/Account
,
actual request should be made to /1crm/api.php/data/Account
.
Call parameters can be passed to API in various ways:
- in endpoint path. Such parameters are listed in this documentation with a colon
prepended, for example
/data/:model
-
in query string, for example
/data/Account?limit=10
. Array and object parameters can be specified using square brackets:/data/Account?object[a][b]=1
/data/Account?array[]=1&array[]=2
- in request body of POST and PUT requests, formatted as JSON object
- in HTTP headers. Note that actual header name is derived from param name by
replacing undersores with hyphens. Header name is case insensitive. For
example,
CONTENT_TYPE
header parameter should be passed inContent-Type
HTTP header
Most API responses are formatted as JSON objects. A successful call result is
indicated with 200 OK
HTTP status code. Any response with status code
different from 200 indicates an error, with detailed error information available
in response body.
REST API is only available in Pro and Enterprise editions of 1CRM. Any attempt
to make an API call to Startup or Startup+ edition will result in 403 Forbidden
status code.
Note that the 1CRM API by default will reject any calls made over a non-SSL
connection (http://
). These connections may be enabled by an option in
Admin - System Settings.
HTTP Method override
1CRM API uses different HTTP methods in API calls. Some client applications may only be able to perform HTTP requests using a limited number of HTTP methods. Also, 1CRM application server may be behind an HTTP proxy that does not accept HTTP methods other than GET and POST. To use 1CRM API in such situations, one can send POST requests instead of PUT, PATCH and DELETE, and add X-HTTP-Method-Override header.
POST /1crm/api.php/data/Account/123 HTTP/1.1
Host: portaldemo.1crmcloud.com
X-HTTP-Method-Override: DELETE
HTTP status codes
-
200 OK
Requested action was executed. Response body may contain the requested data.
-
400 Bad request
Returned if required parameters are missing, or parameters do not match expected data type. Response body contains additional information
-
401 Unauthorized
Returned when client is not authenticated
-
403 Forbidden
Returned when:
- client is not authorized to access requested resource according to 1CRM ACLs
- an API call is made to Startup or Startup+ edition
-
404 Not found
Returned when requested endpoint does not exist, or when requested record does not exist.
-
500 Internal error
Returned when an internal server error occurred. Response body may contain additional information
Endpoints may define additional response codes – see endpoint documentation for details.
Language
Some endpoints, especially metadata-related, may return data that
is locale-dependent. To specify preferred language, use Accept-Language
HTTP
header. If that header is missing, default locale is used as configured in 1CRM
settings. Note that even if Accept-Language
header is present, formatting may
be applied to some data according to authenticated user's locale preferences.
Legend
Authentication required
Request methods
Required parameter
Parameter is located in endpoint path
Parameter is located in query string
Parameter is located in request body
Parameter is located in HTTP header
[1:] [:20] [1:100] numeric values limits, or limits for number of elements in arrays or string length
{String} Type constraint for values in an object, or valid values for Enum type
(123) default value
Extending 1CRM API
Client libraries
Although most programming lanuages provide tools for making HTTP requests, using a dedicated API client library can make a developer’s life easier, to ensure applications follow best practices when using the API, and to make any code using the API more robust.
Currently, 1CRM provides API client library for PHP. Client libraries for other programming languages are under development.
PHP
The 1CRM API Client library for PHP may be found here and its documentation is here.
Authentication
Vast majority of 1CRM API calls require authentication. Upon successful authentication, further API calls respect access rules defined by 1CRM administrator. This includes access to certain modules, access to records belonging to other users, permissions to edit and/or delete records, etc. Basically, any restrictions that apply to a user using 1CRM web UI, also apply to api calls when API client is authenticated on behalf of that user.
1CRM REST API supports 2 authentication mechanisms: Basic authentication and OAuth 2 authentication. OAuth 2 authentication should be preferred if possible.
Basic authentication
HTTP basic authentication is the simplest authentication method accepted by 1CRM
API. Authentication is performed by adding Authorization
header to all
requests. No special authentication request is required.
To perform basic authentication, application should perform the following steps:
- Concatenate user name and password with a colon:
admin:password
- Encode concatenated string as Base64 :
YWRtaW46cGFzc3dvcmQ=
- Add
Authorization
header to the HTTP request:Authorization: Basic YWRtaW46cGFzc3dvcmQ=
While Basic authentication is very simple to use, you should always prefer OAuth 2.0. Note that in 1CRM Implementation Guide, we highly recommend disabling Basic Authentication, and most administrators will do so
OAuth 2 authentication
1CRM API utilizes the industry-standard OAuth 2.0 protocol. You should always prefer OAuth to Basic authentication.
To use OAuth 2.0 authentication, you first need to obtain a token. After that, you should add Authorization
header to HTTP requests when calling endpoints that require authentication : Authorization: Bearer access_token
. Replace access_token
with actual access token.
See OAuth 2.0 for details about obtaining access tokens.
Session authentication
Session authentication is an authentication method for embedded 1CRM applications. Authentication is performed by adding the Session ID
from browser cookies to HTTP requests when calling endpoints that require authentication. The request would be automatically authenticated using the credentials from the current 1CRM session with all user's ACL rights.
Note that Session Authentication is disabled by default
Types
Bool
This type represents a boolean value. Strings yes
, 1
and true
are
recognized as true
, and no
, 0
and false
are recognized as false
.
When sending parameters of this type in request body, prefer using JSON
values of true
or false
instead of strings.
Int
This type represents an integer value. Parameters of this type can have limits set for minumum and maximum accepted values
String
This type represents a generic string value. Parameters of this type can have limits set for minumum and maximum accepted string length and/or regular expression that the string should match
Enum
This type represents a string that can only take one of predefined values
Float
This type represents a floating point numeric value. Parameters of this type can have limits set for minumum and maximum accepted values
Array
This type represents an array of values. Parameters of this type can be either a generic array without a predefined element type, or a typed array that should have only values of specific type as array elements
Object
This type represents a data structure known in different programming languages as associative array, map, symbol table, or dictionary. Object keys are always strings. Parameters of this type can have schema to specify accepted keys and value types for those keys
Date
Inherits String
This type represents a date value. The value must conform to Y-m-d
format as used by
PHP date function
DateTime
Inherits String
This type represents a date/time value. The value must conform to Y-m-d H:i:s
format as used by
PHP date function. Use GMT timezone.
Filename
Inherits String
This type represents a file name. The value should not contain any path information.
OneOf
This is a polymorphic type that can be one of several predefined types.
WebhookFilter
Inherits Object
This type represents a webhook filter.
Name | Type | Description | |
---|---|---|---|
glue | Enum {or, and} | ||
conditions | Array | Depends | |
↳[n] | OneOf (StringFilter, DatetimeFilter, EnumFilter, NumberFilter, BoolFilter, WebhookFilter) |
StringFilter
Inherits Object
This type represents a webhook filter by a string field.
filter
can be one of the following:
eq
field value is equal tovalue
not_eq
field value is not equal tovalue
prefix
field value starts withvalue
suffix
field value ends withvalue
like
field value containsvalue
not_like
field value does not containvalue
empty
field value is emptynot_empty
field value is not empty
Name | Type | Description | |
---|---|---|---|
field | String | Name of the field this filter applies to | |
filter | Enum {eq, not_eq, prefix, suffix, like, not_like, empty, not_empty} | Filter operator | |
value | String | Operand | |
when | WebhookWhen | Type of change |
NumberFilter
Inherits Object
This type represents a webhook filter by a numeric field.
filter
can be one of the following:
lt
field value is less thanvalue
gt
field value is greater thanvalue
lte
field value is less than or equal tovalue
gte
field value is grater than or equal tovalue
between
field value is betweenvalue
andvalue2
, inclusiveempty
field value is not setnot_empty
field value is seteq
field value is equal tovalue
not_eq
field value is not equal tovalue
Name | Type | Description | |
---|---|---|---|
field | String | Name of the field this filter applies to | |
filter | Enum {lt, gt, lte, gte, between, empty, not_empty, eq, not_eq} | Filter operator | |
value | Float | Operand | |
value2 | Float | Second operand | |
when | WebhookWhen | Type of change |
DatetimeFilter
Inherits Object
This type represents a webhook filter by a date or datetime field.
filter
can be one of the following:
not_empty
field value is not emptyempty
field value is emptybefore_date
field value is before the date passed invalue
after_date
field value is after the date passed invalue
on_date
field value equals the date passed invalue
not_on_date
field value does not equal the date passed invalue
yesterday
field value is yesterday's datetoday
field value is today's datetomorrow
field value is tomorrow's datebetween_dates
field value is between dates passed invalue
andvalue2
, inclusive
You can also pass period_prev
, period_current
, or period_next
in filter
.
In this case filed value will be checked against previous, current, or next
period relative to current date. Period length is determined by value
:
day
one dayweek
calendar weekmonth
calendar monthquarter
calendar quarteryear
calendar yearfiscal_quarter
fiscal quarterfiscal_year
fiscal yeardays_N
N days
Name | Type | Description | |
---|---|---|---|
field | String | Name of the field this filter applies to | |
filter | Enum {not_empty, empty, before_date, after_date, on_date, not_on_date, yesterday, today, tomorrow, period_prev, period_current, period_next, between_dates} | Filter operator | |
value | OneOf (Date, DateTime) | Operand | |
value2 | OneOf (Date, DateTime) | Second operand | |
when | WebhookWhen | Type of change |
EnumFilter
Inherits Object
This type represents a webhook filter by a enum or multienum field.
filter
can be one of the following:
eq
field value equalsvalue
; pass a string for enum field or an array of strings for multienum fieldnot_eq
field value not equalsvalue
; pass a string for enum field or an array of strings for multienum fieldany_of
for enum fields, field value is contained invalue
array; for multienum fields, field value contains at least one element from array passed invalue
not_any_of
for enum fields, field value is not contained invalue
array; for multienum fields, field value does not contain any of the elements from array passed invalue
all_of
all elements passed invalue
array are contained in field value; applicable to multienum fields onlyempty
field value is emptynot_empty
field value is not empty
Name | Type | Description | |
---|---|---|---|
field | String | Name of the field this filter applies to | |
filter | Enum {eq, not_eq, any_of, not_any_of, all_of, empty, not_empty} | Filter operator | |
value | OneOf (String, Array {String}) | Operand. When filtering on enum fields, pass a string. For multienum fields, pass an array of strings | |
when | WebhookWhen | Type of change |
BoolFilter
Inherits Object
This type represents a webhook filter by a boolean field.
Name | Type | Description | |
---|---|---|---|
field | String | Name of the field this filter applies to | |
filter | Enum {is_true, is_false} | Filter operator | |
when | WebhookWhen | Type of change |
WebhookWhen
Inherits Enum {changed, not_changed, changed_to, current_value, prev_value}
This type represents the type of change webhook filter reacts to.
changed
Field value was changed. Actual previous and new values are not importantnot_changed
Field value was not changed.changed_to
Field was changed to a value that matches the criteria defined by filter'soperator
current_value
Field's current value matches the criteria defined by filter'soperator
, regardless of whether it was changed or not.prev_value
Field was changed, and its previous value matches the criteria defined by filter'soperator
TestComplex
Inherits Object
This type exists solely for testing purposes. Do not use
Name | Type | Description | |
---|---|---|---|
x | String | ||
y | Int | ||
z | TestComplex | ||
q | DateTime |
Authentication
Authorization request for contact
/auth/contact/authorize
See OAuth 2.0
Name | Type | Description | |
---|---|---|---|
response_type | Enum {code, token} | Expected response type | |
client_id | String | API client identifier | |
redirect_uri | String | This parameter is optional, if not specified, the user will be redirected to a pre-registered redirect URI | |
scope | String | A space delimited list of scopes | |
state | String | CSRF token. This parameter is optional but highly recommended. You should store the value of the CSRF token in the user’s session to be validated when they return |
Authorization request for user
/auth/user/authorize
See OAuth 2.0
Name | Type | Description | |
---|---|---|---|
response_type | Enum {code, token} | Expected response type | |
client_id | String | API client identifier | |
redirect_uri | String | This parameter is optional, if not specified, the user will be redirected to a pre-registered redirect URI | |
scope | String | A space delimited list of scopes | |
state | String | CSRF token. This parameter is optional but highly recommended. You should store the value of the CSRF token in the user’s session to be validated when they return |
Authorization grant for contact
/auth/contact/access_token
See OAuth 2.0
Name | Type | Description | |
---|---|---|---|
grant_type | Enum {client_credentials, password, authorization_code, refresh_token} | Grant type | |
client_id | String | API client identifier | |
client_secret | String | API client secret | |
refresh_token | String | Refresh token | |
redirect_uri | String | This parameter is optional, if not specified, the user will be redirected to a pre-registered redirect URI | |
code | String | Authorization code |
Name | Type | Description | |
---|---|---|---|
token_type | String | Access token type. Always | |
expires_in | Int | An integer representing the TTL of the access token | |
access_token | String | A JWT signed with the authorization server’s private key | |
refresh_token | String | An encrypted payload that can be used to refresh the access token when it expires | |
state | String | State parameter sent in the original request. You should compare this value with the value stored in the user’s session to ensure the authorization code obtained is in response to requests made by this client rather than another client application |
Authorization grant for user
/auth/user/access_token
See OAuth 2.0
Name | Type | Description | |
---|---|---|---|
grant_type | Enum {client_credentials, password, authorization_code, refresh_token} | Grant type | |
client_id | String | API client identifier | |
client_secret | String | API client secret | |
refresh_token | String | Refresh token | |
redirect_uri | String | This parameter is optional, if not specified, the user will be redirected to a pre-registered redirect URI | |
code | String | Authorization code |
Name | Type | Description | |
---|---|---|---|
token_type | String | Access token type. Always | |
expires_in | Int | An integer representing the TTL of the access token | |
access_token | String | A JWT signed with the authorization server’s private key | |
refresh_token | String | An encrypted payload that can be used to refresh the access token when it expires | |
state | String | State parameter sent in the original request. You should compare this value with the value stored in the user’s session to ensure the authorization code obtained is in response to requests made by this client rather than another client application |
List Filters
Apply
Two endpoints which return a list of records, Get list of records and Get list of related records, support two query parameters to get a specific data set.
filter_text
- Generic search string. Fields involved in search depend on amodel
. Include this parameter to a query for filtering a list of records by Subject, Name, # (like Invoice #) etc.
Examples:/api.php/data/Invoice?filter_text=2020-100
api.php/data/Task?filter_text=Send%20Contract
filters
- A list of filters to apply. To get a list of available filters for a model, use metadata endpoint. Some filters differ from field names. Check a model metadata carefully to avoid mistakes. For example if you want filtering records by email you have to useany_email
filter parameter instead ofemail1
oremail2
.
Examples:/api.php/data/Account?filters[account_type]=Supplier&filters[any_email]=sales@1crm.com
Also for some filters you can use a part of the value like this -api.php/data/Account?filters[any_email]=sales
For Ref fields (e.g. Billing Account, Primary Contact etc.) there are two ways of filter applying:- Using text value of Ref field, e.g. Account Name -
/api.php/data/Invoice?filters[billing_account]=Microsoft
- Using ID. You can find the correct name of a filter for this case in a filter metadata, under
id_name
-/data/Invoice?filters[billing_account_id]=2e1a3464-47e0-5201-4a5c-5c9b25575447
- Using text value of Ref field, e.g. Account Name -
-
Date Filters: filtering by date fields may require additional parameters. The most used second parameter for the date filter is
operator
. If you omitoperator
parameter the default value will beon_date
.
All possibleoperator
parameter values:not_empty
field value is not empty (provided without date_field value)empty
field value is empty (provided without date_field value)before_date
field value is before the date passed in a queryafter_date
field value is after the date passed in a queryon_date
field value equals the date passed in a querynot_on_date
field value does not equal the date passed in w queryyesterday
field value is yesterday's date (provided without date_field value)today
field value is today's date (provided without date_field value)tomorrow
field value is tomorrow's date (provided without date_field value)between_dates
field value is between dates passed query, inclusive (required end date valuedate_field-end
)
You can also passperiod_prev
,period_current
, orperiod_next
asoperator
value. In this case filed value will be checked against previous, current, or next period relative to current date. Period length is determined bydate_field-period
parameter:day
one dayweek
calendar weekmonth
calendar monthquarter
calendar quarteryear
calendar yearfiscal_quarter
fiscal quarterfiscal_year
fiscal yeardays_N
N days (dayes_7, days_14, days_30, etc)
Examples:
/api.php/data/Invoice?filters[due_date]=2020-01-01
- get all invoices withdue_date
= '2020-01-01' (due_date-operator
= 'on_date' by default)
/api.php/data/Invoice?filters[due_date]=2020-01-01&filters[due_date-operator]=before_date
- get all invoices withdue_date
< '2020-01-01'/api.php/data/Invoice?filters[due_date-operator]=empty
- get all invoices with emptydue_date
value/api.php/data/Invoice?filters[due_date]=2020-01-01&filters[due_date-end]=2020-02-01&filters[due_date-operator]=between_dates
- get all invoices withdue_date
>= '2020-01-01' ANDdue_date
<= '2020-02-01'/api.php/data/Invoice?filters[due_date-operator]=period_prev&filters[due_date-period]=week
- get all invoices withdue_date
between start and end of previous week from today
Working with data
Add or remove a record from user's favorites
/data/favorites/{model}/{id}
Name | Type | Description | |
---|---|---|---|
status | Int | New favorite status. 0 if added, 1 if removed |
Get list of records
/data/{model}
Retrieve list of records belonging to specified model
Returned objects do not have a predefined structure, it depends on model and requested fields. See Metadata
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
fields | Array | Array of field names to fetch. When omitted, a limited number of fields are returned, depending on model. Record ID is guaranteed to be returned, and for most models, | |
↳[n] | String | ||
query_favorite | Bool | Query favorites. If set, | |
filter_text | String | Generic search string. Fields involved in search depend on model | |
filters | Object {String} | Filters to apply. To get list of available filters for a model, use metadata | |
order | String | Sort order | |
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
total_results | Int | Total number of results, without taking offset and limit in account |
Create records
/data/{model}
Create a record of specified model
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model | |
data | Object | An object with keys matching field names to update. Fields not defined in this object are not modified |
Name | Type | Description | |
---|---|---|---|
id | String | ID of created record |
Get single record
/data/{model}/{id}
Retrieve single record belonging to specified model
, identified by id
Returned object does not have a predefined structure, it depends on model and requested fields. See Metadata
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
id | String [1:] | Record ID | |
fields | Array | Array of field names to fetch. When omitted, all available fields are returned. | |
↳[n] | String |
Name | Type | Description | |
---|---|---|---|
record | Object | Retrieved record |
Update a record
/data/{model}/{id}
Update record belonging to specified model
, identified by id
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
id | String [1:] | Record ID | |
data | Object | An object with keys matching field names to update. Fields not defined in this object are not modified | |
create | Bool | If true, record will be created if it does not exist |
Name | Type | Description | |
---|---|---|---|
result | Bool | Always true |
Delete a record
/data/{model}/{id}
Delete record belonging to specified model
, identified by id
Name | Type | Description | |
---|---|---|---|
result | Bool | True if deleted successfully |
Get list of related records
/data/{model}/{id}/{link}
Retrieve list of related records belonging to specified model
and id
via
specific link
Returned objects do not have a predefined structure, it depends on model and requested fields. See Metadata
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
id | String [1:] | Record ID | |
link | String [1:] | Link name | |
fields | Array | Array of field names to fetch. When omitted, a limited number of fields are returned, depending on model. Record ID is guaranteed to be returned, and for most models, | |
↳[n] | String | ||
filter_text | String | Generic search string. Fields involved in search depend on model | |
filters | Object {String} | Filters to apply. To get list of available filters for a model, use metadata | |
order | String | Sort order | |
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
total_results | Int | Total number of results, without taking offset and limit in account |
Add related records
/data/{model}/{id}/{link}
Add list of related records belonging to specified model
and id
via specific link
.
You can specify related records in 2 ways:
- Pass an array of related IDs in
records
parameter. This is suitable for most links, where you just want to set relationship between records, without specifying additional link data. Example: linking Contact to Account. -
Pass an array of objects with additional data to be inserted into join table in
records_with_data
parameter. For example, when adding a product to assembly, you want to specify the quantity of products in the assembly. Imagine you want to add 5 products with ID3d3e96d1-8d7c-acd6-e338-55b9b0cc5aae
to assembly with ID5121670a-9ddb-8330-195d-5979fc9a6906
. Then you POST to/data/Assembly/5121670a-9ddb-8330-195d-5979fc9a6906/products
, and pass the following JSON in request body:{ "records_with_data": [ { "id": "3d3e96d1-8d7c-acd6-e338-55b9b0cc5aae", "quantity" : 5 } ] }
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Parent model | |
id | String [1:] | Parent ID | |
link | String [1:] | Link name | |
records | Array | Array of related record IDs to be added to specified link | |
↳[n] | String [1:] | ||
records_with_data | Array | Array of objects, each representing additional data to be inserted into join table | |
↳[n] | Object |
Remove relationship between records
/data/{model}/{id}/{link}/{rel_id}
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Parent model | |
id | String [1:] | Parent record ID | |
link | String [1:] | Link name | |
rel_id | String [1:] | Related record ID |
Name | Type | Description | |
---|---|---|---|
result | Bool | True if deleted successfully |
Get list of all related records
/data/link/{model}/linked-records/{link}
Retrieve list of all related records belonging to specified model
via
specific link
Returned objects do not have a predefined structure, it depends on model and requested fields. See Metadata
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
link | String [1:] | Link name | |
fields | Array | Array of field names to fetch. When omitted, a limited number of fields are returned, depending on model. Record ID is guaranteed to be returned, and for most models, | |
↳[n] | String | ||
order | String | Sort order | |
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
total_results | Int | Total number of results, without taking offset and limit in account |
Erase Personal Data
/data/erase_personal/{model}/{id}
Erase Personal Data belonging to specified model
, identified by id
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
id | String [1:] | Record ID | |
data | Object | An object with |
Name | Type | Description | |
---|---|---|---|
result | Bool | Always true |
Tally Objects
1CRM includes a set of modules that have a common property: each record from those modules contains a list of related line items. This includes records that represent financial transactions (Quotes, Invoices, Bills etc.) and moves of goods (Shipping, Receiving). Records from such modules are collectively referred to as Tally Objects. 1CRM API provides a set of endpoints for working with such objects that allow to treat the Tally objects as a whole, not as separate "parent" record (for example, invoice) and a set if line items.
Get a Tally Object
/tally/{model}/{id}
Name | Type | Description | |
---|---|---|---|
record | Object | "Parent" record as if it was retrieved using | |
groups | Array | Array of groups, each group contains one or more line items |
Working with calendars
Get list of events
/calendar/events
Retrieve list of events within specified dates range. Returned records are grouped by type, and within each type records are sorted by date. No more than 200 records of each type are returned.
Name | Type | Description | |
---|---|---|---|
start_date | DateTime | Lower date bound | |
end_date | DateTime | Upper date bound | |
types | Array | When present, this parameter limits returned events to specified types | |
↳[n] | Enum {Call, Meeting, Task, ProjectTask} |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
↳[id] | String | Record ID | |
↳[start_date] | DateTime | Event start date/time | |
↳[due_date] | DateTime | Event due date/time | |
↳[name] | String | Event name | |
↳[type] | Enum {Call, Meeting, Task, ProjectTask} | Event type | |
↳[location] | String | Event location, if applicable |
Working with metadata
Get fields definition for a model
/meta/fields/{model}
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query |
Name | Type | Description | |
---|---|---|---|
fields | Array | An array with fields definitions | |
filters | Array | An array with filters definitions |
Get locale-related information
/meta/locale
Retrieve information about how 1CRM is configured to format numbers, addresses and currency values
Date and time formats are as defined in the documentation of PHP date() function.
Name format can contain s, f and l placeholders, for salutation, first name and last name, respectively.
Address format can contain placeholders. A placeholder constist of a letter between curly braces:
- {s} for street address
- {c} for city
- {t} for state
- {o} for country
- {p} for postal code
- {a} for company name
- {n} for contact name
- {d} for department
- {h} for phone
- {f} for fax
|
(pipe symbol) denotes a space, [ ]
(a space in square bracket) is for new line.
Name | Type | Description | |
---|---|---|---|
date_format | String | Date format | |
time_format | String | Time format | |
address_format | Object | Address format | |
↳[display] | String | Address format descriptive name | |
↳[format] | String | Address format | |
number_format | Object | Number format | |
↳[display] | String | Number format descriptive name | |
↳[dec_sep] | String | Deciamal part separator | |
↳[grp_sep] | String | Groups separator | |
base_currency | Object | Base currency | |
↳[name] | String | Currency name | |
↳[iso4217] | String | Currency code according to ISO 4217 | |
↳[symbol] | String | Currency symbol | |
↳[significant_digits] | Int | Number of symbols after decimal point | |
↳[symbol_place_after] | Bool |
| |
↳[space_separate] | Bool |
|
Get list of available modules
/meta/modules
Name | Type | Description | |
---|---|---|---|
list | Array | List of modules | |
↳[n] | Object | ||
↳[module] | String | Module name | |
↳[primary_model] | String | Module's primary model | |
↳[models] | Array | Models | |
↳[n] | String | Model name |
Get ListView metadata for a model
/meta/list_view/{model}
Retrieve ListView metadata belonging to specified model
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
layout | String | Get metadata for this layout |
Name | Type | Description | |
---|---|---|---|
current_layout | Array | An array with current ListView layout (tab) params | |
layouts | Array | Array of all ListView layouts for the module | |
↳[n] | Object | ||
settings | Object | An array with Listview layout settings | |
hooks | Array | An array with ListView hooks | |
columns | Array | Array of ListView columns | |
↳[n] | Object | ||
filters | Array | Array of filters for the current layout | |
↳[n] | Object | ||
hidden_fields | Array | Array of hidden fields | |
↳[n] | Object | ||
mass_update | Array | Mass Update details - buttons and fields | |
↳[n] | Array | ||
↳[buttons] | Array | ListView mass update buttons(actions) | |
↳[fields] | Array | Mass update form fields |
Get Sub Panels metadata for a model
/meta/sub_panels/{model}/{detail_layout}
Retrieve Sub Panels metadata belonging to specified model
and detail_layout
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
detail_layout | String [1:] | DetailView layout (tab) |
Name | Type | Description | |
---|---|---|---|
panels | Array | A list of SubPanels with metadata | |
↳[n] | Object | ||
↳[name] | String | SubPanel name | |
↳[module] | String | SubPanel module | |
↳[bean_name] | String | SubPanel model name | |
↳[model_type] | String | SubPanel model type | |
↳[managed] | Bool | ||
↳[removeable] | Bool | ||
↳[updateable] | Bool | ||
↳[no_create] | Bool | Hide Create button if true | |
↳[icon] | String | Custom icon | |
↳[detail_link_url] | String | Custom DetailView URL | |
↳[detail_link_action] | String | Custom DetailView Action | |
↳[layout] | String | SubPanel layout name | |
↳[layout_type] | String | SubPanel layout type | |
↳[title] | String | Title lang constant | |
↳[target_key] | Bool | Target Key | |
↳[source_key] | Bool | Source Key | |
↳[custom_buttons] | Array | An array with SubPanel custom buttons | |
↳[columns] | Array | An array with SubPanel columns |
Get DetailView metadata for a model
/meta/detail_view/{model}/{layout}
Retrieve DetailView metadata belonging to specified model
and layout
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
layout | String [1:] | Selected DetailView layout |
Name | Type | Description | |
---|---|---|---|
title | String | Form title | |
current_layout | Array | An array with current DetailView layout (tab) params | |
layouts | Array | An Array of all DetailView layouts(tabs) for the module | |
↳[n] | Object | ||
buttons | Array | An Array of custom module DetailView buttons | |
↳[n] | Object | ||
scripts | Array | An array of custom scripts which should be included | |
form_hooks | Array | An array of custom form hooks | |
↳[n] | Object | ||
summary | Object | Summary part of the detail page | |
sections | Array | An array of detail page sections | |
↳[n] | Object |
Get generic module metadata
/meta/generic_module_layouts/{module}
Generic module metadata - default list, detail, popup layouts
Name | Type | Description | |
---|---|---|---|
module | String [1:] | Module |
Name | Type | Description | |
---|---|---|---|
list | Array | Default ListView layout and view | |
popup | Array | Default Popup layout and view | |
detail | Array | Default DetailView layout and view |
Working with files
Upload a small file
/files/upload/base64
Upload a file. Uploaded file will be saved to a temporary location. Returned
file ID can be used as a value for fields having file_ref
or image
type when
creating or updating
records.
This endpoint is suitable for uploading relatively small files, such as contact or user photos. Request body length should not exceed 1048576 bytes.
Note that uploaded files will be kept on server for a limited amount of time if
not linked in file_ref
or image
field after upload.
Name | Type | Description | |
---|---|---|---|
filename | Filename [1:] | File name | |
mimetype | String [1:] | File MIME type | |
data | String | File data, |
Name | Type | Description | |
---|---|---|---|
id | String | Uploaded file ID |
Upload a file
/files/upload
Upload a file. Uploaded file will be saved to a temporary location. Returned
file ID can be used as a value for fields having file_ref
or image
type when
creating or updating
records.
This endpoint is suitable for uploading larger files, compared to
/files/upload/base64
. File size limit
depends on maximum post size defined in PHP configuration.
Note that uploaded files will be kept on server for a limited amount of time if
not linked in file_ref
or image
field after upload.
Name | Type | Description | |
---|---|---|---|
CONTENT_TYPE | String (application/octet-stream) | File content type | |
CONTENT_LENGTH | Int [0:] | File size | |
X_ONECRM_FILENAME | Filename [1:] | File name |
Name | Type | Description | |
---|---|---|---|
id | String | Uploaded file ID |
Download a file
/files/download/{model}/{id}
Download a file.
This endpoint is for downloading 1CRM Documents and Note attachments
File source is identified with model
and id
parameters:
- When
model
equals toDocument
, latest document revision will be downloaded.id
is the Document ID - When
model
equals toDocumentRevision
, specific document revision will be downloaded.id
is the Document Revision ID - When
model
equals toNotes
, note attachment will be downloaded,id
is Note ID
On success, the response body contains raw file data. Additional information
may be returned in Content-Type
, Content-Length
, Content-Disposition
, and
X-OneCRM-Filename
response headers.
On failure, HTTP response code different from 200 will be returned, and response body contains additional information in JSON format.
Get information about a file
/files/info/{model}/{id}
Get information about a file.
This endpoint is for Retrieving metadata for 1CRM Documents and Note attachments.
See /files/download/:model/:id for description
of model
and id
parameters.
Name | Type | Description | |
---|---|---|---|
name | String | File name | |
mimetype | String | File MIME type | |
modified | Int | File modification time, in secons since UNIX epoch | |
size | Int | File sizee in bytes | |
temp_url | String | Temporary download URL |
Webhooks
A Webhook is an HTTP callback: an HTTP POST that occurs when something happens; a simple event-notification via HTTP POST.
In 1CRM, 3 types of webhooks are available create
, update
and
create_update
. Webhook type determines the event that triggers the
notification. create
webhooks are triggered when a new record is created.
update
webhooks are triggered when an existing record is updated.
create_update
webhooks are triggered for both new records and updated records.
When a webhook is triggered, a HTTP POST request is sent to specified URL.
Content-Type
header is set to application/json
, and a JSON object is passed
in request body. The object contains the values of record's fields after the
update.
When a record is updated, first all webhooks with corresponding type
and
model
are selected. Then each webhook is examined for the user that created it.
If the user has no read access to the updated record, the webhook will be
excluded from further examination. Next, for each webhook, each filter from
filters
is examined:
- if
glue
isand
, and all conditions fromfilters
are satisfied, the webhook triggers - if
glue
isor
, and at least one condition fromfilters
is satisfied, the webhook triggers
Click here to see examples of webhook filters.
Get List of webhooks
/webhooks
Get List of webhooks
Name | Type | Description | |
---|---|---|---|
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
total_results | Int | Total number of results, without taking offset and limit in account | |
records | Array | ||
↳[n] | Object | ||
↳[id] | String | Webhook ID | |
↳[type] | String | Webhook type | |
↳[url] | String | Webhook URL | |
↳[model] | String | Model that triggers this webhook | |
↳[filters] | WebhookFilter | Model-specific filters | |
↳[assigned_user_id] | String | User assigned to the webhook |
Create a webhook
/webhooks
Name | Type | Description | |
---|---|---|---|
type | Enum {create, update, create_update} | Webhook type | |
url | String [1:] | Webhook URL | |
model | String [1:] | Model that triggers this webhook | |
filters | WebhookFilter | Describes filters to trigger webhook on specific events only. |
Name | Type | Description | |
---|---|---|---|
id | String | Webhook ID | |
type | String | Webhook type | |
url | String | Webhook URL | |
model | String | Model that triggers this webhook | |
filters | WebhookFilter | Model-specific filters |
Delete a webhook
/webhooks/{id}
Delete webhook identified by id
Name | Type | Description | |
---|---|---|---|
id | String [1:] | Webhook ID |
Name | Type | Description | |
---|---|---|---|
id | String | Webhook ID | |
type | String | Webhook type | |
url | String | Webhook URL | |
model | String | Model that triggers this webhook |
Get a webhook
/webhooks/{id}
Get data for webhook identified by id
Name | Type | Description | |
---|---|---|---|
id | String [1:] | Webhook ID |
Name | Type | Description | |
---|---|---|---|
id | String | Webhook ID | |
type | String | Webhook type | |
url | String | Webhook URL | |
model | String | Model that triggers this webhook | |
filters | WebhookFilter | Model-specific filters. |
Update a webhook
/webhooks/{id}
Name | Type | Description | |
---|---|---|---|
id | String [1:] | Webhook ID | |
type | Enum {create, update, create_update} | Webhook type | |
url | String [1:] | Webhook URL | |
model | String [1:] | Model that triggers this webhook | |
filters | WebhookFilter | Describes filters to trigger webhook on specific events only. |
Name | Type | Description | |
---|---|---|---|
id | String | Webhook ID | |
type | String | Webhook type | |
url | String | Webhook URL | |
model | String | Model that triggers this webhook | |
filters | WebhookFilter | Model-specific filters |
Portal
Create access token for portal user
/portal/auth
Create a new access token to be used for portal access. Returned access token allows access to a limited subset of data that is relevant for certain contact only.
Name | Type | Description | |
---|---|---|---|
contact_id | String [1:] | Contact ID |
Utility
Get information about authenticated user
/me
Name | Type | Description | |
---|---|---|---|
id | String | User ID | |
name | String | User name | |
first_name | String | First name | |
last_name | String | Last name | |
role | String | User role | |
groups | Array | User groups | |
String | User email | ||
timezone | String | User's timezone |
Get server public key
/public_key
Name | Type | Description | |
---|---|---|---|
key | String | Contents of server public key |
Get 1CRM version
/version
Returns 1CRM version. Can be used to validate login info
Name | Type | Description | |
---|---|---|---|
version | String | 1CRM version | |
products | Array | List if licensed products | |
↳[n] | String | ||
authenticated | Bool | True if the request contains valid authentication header |
Print PDF
Print PDF
/printer/pdf/{model}/{id}
Print Personal Data PDF
/printer/pdf/personal/{model}/{id}
Audit
Get list of audit logs
/audit/{model}
Retrieve list of audit logs belonging to specified model
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
total_results | Int | Total number of results, without taking offset and limit |
Get parent record audit logs
/audit/{model}/{id}
Retrieve list of audit logs belonging to specified model
, identified by parent record id
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
id | String [1:] | Parent Record ID (audited record ID) | |
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
total_results | Int | Total number of results, without taking offset and limit |
Reports
Get list of reports
/reports/{model}
Retrieve list of reports belonging to specified model
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
total_results | Int | Total number of results, without taking offset and limit |
Get list of archived runs
/reports/{model}/{id}
Retrieve list of archived runs belonging to specified model
, identified by report id
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
id | String [1:] | Report ID | |
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
total_results | Int | Total number of results, without taking offset and limit |
Get report data
/reports/data/{model}/{id}
Retrieve archived runs report data belonging to specified model
, identified by run id
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model to query | |
id | String [1:] | Run ID | |
offset | Int [0:] (0) | Offset in the list to start retrieval from | |
limit | Int [1:200] (20) | Limits number of records returned |
Name | Type | Description | |
---|---|---|---|
records | Array | Array of retrieved records | |
↳[n] | Object | ||
total_results | Int | Total number of results, without taking offset and limit |
Working with list and detail layouts
Set ListView layout(tab) params for a model
/layouts/list_view/{model}
Set ListView layout(tab) params belonging to specified model
Name | Type | Description | |
---|---|---|---|
model | String [1:] | Model | |
layout | String [1:] | New selected ListView layout(tab) | |
filter_layout | String [1:] | Filters form layout | |
filter_values | Array | Array of list filters values | |
offset | Int [0:] (0) | ListView offset value | |
limit | Int [1:200] (20) | ListView limit - number of records returned | |
order_by | String | Sort order |