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:

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

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:

  1. Concatenate user name and password with a colon: admin:password
  2. Encode concatenated string as Base64 : YWRtaW46cGFzc3dvcmQ=
  3. 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.

Schema
Name Type Description
glueEnum {or, and}
conditionsArray

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:

Schema
Name Type Description
fieldString

Name of the field this filter applies to

filterEnum {eq, not_eq, prefix, suffix, like, not_like, empty, not_empty}

Filter operator

valueString

Operand

whenWebhookWhen

Type of change

NumberFilter

Inherits Object

This type represents a webhook filter by a numeric field.

filter can be one of the following:

Schema
Name Type Description
fieldString

Name of the field this filter applies to

filterEnum {lt, gt, lte, gte, between, empty, not_empty, eq, not_eq}

Filter operator

valueFloat

Operand

value2Float

Second operand

whenWebhookWhen

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:

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:

Schema
Name Type Description
fieldString

Name of the field this filter applies to

filterEnum {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

valueOneOf (Date, DateTime)

Operand

value2OneOf (Date, DateTime)

Second operand

whenWebhookWhen

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:

Schema
Name Type Description
fieldString

Name of the field this filter applies to

filterEnum {eq, not_eq, any_of, not_any_of, all_of, empty, not_empty}

Filter operator

valueOneOf (String, Array {String})

Operand. When filtering on enum fields, pass a string. For multienum fields, pass an array of strings

whenWebhookWhen

Type of change

BoolFilter

Inherits Object

This type represents a webhook filter by a boolean field.

Schema
Name Type Description
fieldString

Name of the field this filter applies to

filterEnum {is_true, is_false}

Filter operator

whenWebhookWhen

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.

TestComplex

Inherits Object

This type exists solely for testing purposes. Do not use

Schema
Name Type Description
xString
yInt
zTestComplex
qDateTime

Authentication

Authorization request for contact

/auth/contact/authorize

See OAuth 2.0

Parameters
Name Type Description
response_typeEnum {code, token}

Expected response type

client_idString

API client identifier

redirect_uriString

This parameter is optional, if not specified, the user will be redirected to a pre-registered redirect URI

scopeString

A space delimited list of scopes

stateString

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

Parameters
Name Type Description
response_typeEnum {code, token}

Expected response type

client_idString

API client identifier

redirect_uriString

This parameter is optional, if not specified, the user will be redirected to a pre-registered redirect URI

scopeString

A space delimited list of scopes

stateString

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

Parameters
Name Type Description
grant_typeEnum {client_credentials, password, authorization_code, refresh_token}

Grant type

client_idString

API client identifier

client_secretString

API client secret

refresh_tokenString

Refresh token

redirect_uriString

This parameter is optional, if not specified, the user will be redirected to a pre-registered redirect URI

codeString

Authorization code

Return
Name Type Description
token_typeString

Access token type. Always Bearer

expires_inInt

An integer representing the TTL of the access token

access_tokenString

A JWT signed with the authorization server’s private key

refresh_tokenString

An encrypted payload that can be used to refresh the access token when it expires

stateString

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

Parameters
Name Type Description
grant_typeEnum {client_credentials, password, authorization_code, refresh_token}

Grant type

client_idString

API client identifier

client_secretString

API client secret

refresh_tokenString

Refresh token

redirect_uriString

This parameter is optional, if not specified, the user will be redirected to a pre-registered redirect URI

codeString

Authorization code

Return
Name Type Description
token_typeString

Access token type. Always Bearer

expires_inInt

An integer representing the TTL of the access token

access_tokenString

A JWT signed with the authorization server’s private key

refresh_tokenString

An encrypted payload that can be used to refresh the access token when it expires

stateString

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.

  1. filter_text - Generic search string. Fields involved in search depend on a model. 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
  2. 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 use any_email filter parameter instead of email1 or email2.
    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:
    1. Using text value of Ref field, e.g. Account Name - /api.php/data/Invoice?filters[billing_account]=Microsoft
    2. 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
  3. Date Filters: filtering by date fields may require additional parameters. The most used second parameter for the date filter is operator. If you omit operator parameter the default value will be on_date.
    All possible operator 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 query
    • after_date field value is after the date passed in a query
    • on_date field value equals the date passed in a query
    • not_on_date field value does not equal the date passed in w query
    • yesterday 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 value date_field-end)

      You can also pass period_prev, period_current, or period_next as operator value. In this case filed value will be checked against previous, current, or next period relative to current date. Period length is determined by date_field-period parameter:
    • day one day
    • week calendar week
    • month calendar month
    • quarter calendar quarter
    • year calendar year
    • fiscal_quarter fiscal quarter
    • fiscal_year fiscal year
    • days_N N days (dayes_7, days_14, days_30, etc)

    Examples:
    /api.php/data/Invoice?filters[due_date]=2020-01-01 - get all invoices with due_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 with due_date < '2020-01-01' /api.php/data/Invoice?filters[due_date-operator]=empty - get all invoices with empty due_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 with due_date >= '2020-01-01' AND due_date <= '2020-02-01'
    /api.php/data/Invoice?filters[due_date-operator]=period_prev&filters[due_date-period]=week - get all invoices with due_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}
Parameters
Name Type Description
modelString [1:]

Model

idString [1:]

Record ID

Return
Name Type Description
statusInt

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

Parameters
Name Type Description
modelString [1:]

Model to query

fieldsArray

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, name and/or _display fields.

↳[n]String
query_favoriteBool

Query favorites. If set, favorite field will be added to each result row, indicating whether the current user added the item to Favorites. Note that item is in favorites if and only if the value of favorite field is zero

filter_textString

Generic search string. Fields involved in search depend on model

filtersObject {String}

Filters to apply. To get list of available filters for a model, use metadata

orderString

Sort order

offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
recordsArray

Array of retrieved records

↳[n]Object
total_resultsInt

Total number of results, without taking offset and limit in account

Create records

 /data/{model}

Create a record of specified model

Parameters
Name Type Description
modelString [1:]

Model

dataObject

An object with keys matching field names to update. Fields not defined in this object are not modified

Return
Name Type Description
idString

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

Parameters
Name Type Description
modelString [1:]

Model to query

idString [1:]

Record ID

fieldsArray

Array of field names to fetch. When omitted, all available fields are returned.

↳[n]String
Return
Name Type Description
recordObject

Retrieved record

Update a record

 /data/{model}/{id}

Update record belonging to specified model, identified by id

Parameters
Name Type Description
modelString [1:]

Model to query

idString [1:]

Record ID

dataObject

An object with keys matching field names to update. Fields not defined in this object are not modified

createBool

If true, record will be created if it does not exist

Return
Name Type Description
resultBool

Always true

Delete a record

 /data/{model}/{id}

Delete record belonging to specified model, identified by id

Parameters
Name Type Description
modelString [1:]

Model

idString [1:]

Record ID

Return
Name Type Description
resultBool

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

Parameters
Name Type Description
modelString [1:]

Model to query

idString [1:]

Record ID

linkString [1:]

Link name

fieldsArray

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, name and/or _display fields.

↳[n]String
filter_textString

Generic search string. Fields involved in search depend on model

filtersObject {String}

Filters to apply. To get list of available filters for a model, use metadata

orderString

Sort order

offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
recordsArray

Array of retrieved records

↳[n]Object
total_resultsInt

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:

  1. 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.
  2. 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 ID 3d3e96d1-8d7c-acd6-e338-55b9b0cc5aae to assembly with ID 5121670a-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
           }
       ]
    }
Parameters
Name Type Description
modelString [1:]

Parent model

idString [1:]

Parent ID

linkString [1:]

Link name

recordsArray

Array of related record IDs to be added to specified link

↳[n]String [1:]
records_with_dataArray

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}
Parameters
Name Type Description
modelString [1:]

Parent model

idString [1:]

Parent record ID

linkString [1:]

Link name

rel_idString [1:]

Related record ID

Return
Name Type Description
resultBool

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

Parameters
Name Type Description
modelString [1:]

Model to query

linkString [1:]

Link name

fieldsArray

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, name and/or _display fields.

↳[n]String
orderString

Sort order

offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
recordsArray

Array of retrieved records

↳[n]Object
total_resultsInt

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

Parameters
Name Type Description
modelString [1:]

Model to query

idString [1:]

Record ID

dataObject

An object with fields property with the string of comma separated fields for erase. Fields not added to this string are not erased.

Return
Name Type Description
resultBool

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}
Parameters
Name Type Description
modelString [1:]

Model to query

idString [1:]

Record ID

Return
Name Type Description
recordObject

"Parent" record as if it was retrieved using /data/{model}/{id} endpoint

groupsArray

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.

Parameters
Name Type Description
start_dateDateTime

Lower date bound

end_dateDateTime

Upper date bound

typesArray

When present, this parameter limits returned events to specified types

↳[n]Enum {Call, Meeting, Task, ProjectTask}
Return
Name Type Description
recordsArray

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}
Parameters
Name Type Description
modelString [1:]

Model to query

Return
Name Type Description
fieldsArray

An array with fields definitions

filtersArray

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:

| (pipe symbol) denotes a space, [ ] (a space in square bracket) is for new line.

Return
Name Type Description
date_formatString

Date format

time_formatString

Time format

address_formatObject

Address format

↳[display]String

Address format descriptive name

↳[format]String

Address format

number_formatObject

Number format

↳[display]String

Number format descriptive name

↳[dec_sep]String

Deciamal part separator

↳[grp_sep]String

Groups separator

base_currencyObject

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

true if symbol must be placed after amount in monetary values, false if the symbol goes before amount

↳[space_separate]Bool

true if a space is required between numeric value and currency symbol

Get list of available modules

 /meta/modules
Return
Name Type Description
listArray

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

Parameters
Name Type Description
modelString [1:]

Model to query

layoutString

Get metadata for this layout

Return
Name Type Description
current_layoutArray

An array with current ListView layout (tab) params

layoutsArray

Array of all ListView layouts for the module

↳[n]Object
settingsObject

An array with Listview layout settings

hooksArray

An array with ListView hooks

columnsArray

Array of ListView columns

↳[n]Object
filtersArray

Array of filters for the current layout

↳[n]Object
hidden_fieldsArray

Array of hidden fields

↳[n]Object
mass_updateArray

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

Parameters
Name Type Description
modelString [1:]

Model to query

detail_layoutString [1:]

DetailView layout (tab)

Return
Name Type Description
panelsArray

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

Parameters
Name Type Description
modelString [1:]

Model to query

layoutString [1:]

Selected DetailView layout

Return
Name Type Description
titleString

Form title

current_layoutArray

An array with current DetailView layout (tab) params

layoutsArray

An Array of all DetailView layouts(tabs) for the module

↳[n]Object
buttonsArray

An Array of custom module DetailView buttons

↳[n]Object
scriptsArray

An array of custom scripts which should be included

form_hooksArray

An array of custom form hooks

↳[n]Object
summaryObject

Summary part of the detail page

sectionsArray

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

Parameters
Name Type Description
moduleString [1:]

Module

Return
Name Type Description
listArray

Default ListView layout and view

popupArray

Default Popup layout and view

detailArray

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.

Parameters
Name Type Description
filenameFilename [1:]

File name

mimetypeString [1:]

File MIME type

dataString

File data, base64 encoded

Return
Name Type Description
idString

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.

Parameters
Name Type Description
CONTENT_TYPEString (application/octet-stream)

File content type

CONTENT_LENGTHInt [0:]

File size

X_ONECRM_FILENAMEFilename [1:]

File name

Return
Name Type Description
idString

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:

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.

Parameters
Name Type Description
modelEnum

Specifies model

idString [1:]

Specifies ID

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.

Parameters
Name Type Description
modelEnum

Specifies model

idString [1:]

Specifies ID

Return
Name Type Description
nameString

File name

mimetypeString

File MIME type

modifiedInt

File modification time, in secons since UNIX epoch

sizeInt

File sizee in bytes

temp_urlString

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:

Click here to see examples of webhook filters.

Get List of webhooks

 /webhooks

Get List of webhooks

Parameters
Name Type Description
offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
total_resultsInt

Total number of results, without taking offset and limit in account

recordsArray
↳[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
Parameters
Name Type Description
typeEnum {create, update, create_update}

Webhook type

urlString [1:]

Webhook URL

modelString [1:]

Model that triggers this webhook

filtersWebhookFilter

Describes filters to trigger webhook on specific events only.

Return
Name Type Description
idString

Webhook ID

typeString

Webhook type

urlString

Webhook URL

modelString

Model that triggers this webhook

filtersWebhookFilter

Model-specific filters

Delete a webhook

 /webhooks/{id}

Delete webhook identified by id

Parameters
Name Type Description
idString [1:]

Webhook ID

Return
Name Type Description
idString

Webhook ID

typeString

Webhook type

urlString

Webhook URL

modelString

Model that triggers this webhook

Get a webhook

 /webhooks/{id}

Get data for webhook identified by id

Parameters
Name Type Description
idString [1:]

Webhook ID

Return
Name Type Description
idString

Webhook ID

typeString

Webhook type

urlString

Webhook URL

modelString

Model that triggers this webhook

filtersWebhookFilter

Model-specific filters.

Update a webhook

 /webhooks/{id}
Parameters
Name Type Description
idString [1:]

Webhook ID

typeEnum {create, update, create_update}

Webhook type

urlString [1:]

Webhook URL

modelString [1:]

Model that triggers this webhook

filtersWebhookFilter

Describes filters to trigger webhook on specific events only.

Return
Name Type Description
idString

Webhook ID

typeString

Webhook type

urlString

Webhook URL

modelString

Model that triggers this webhook

filtersWebhookFilter

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.

Parameters
Name Type Description
contact_idString [1:]

Contact ID

Utility

Get information about authenticated user

 /me
Return
Name Type Description
idString

User ID

nameString

User name

first_nameString

First name

last_nameString

Last name

roleString

User role

groupsArray

User groups

emailString

User email

timezoneString

User's timezone

Get server public key

/public_key
Return
Name Type Description
keyString

Contents of server public key

Get 1CRM version

/version

Returns 1CRM version. Can be used to validate login info

Return
Name Type Description
versionString

1CRM version

productsArray

List if licensed products

↳[n]String
authenticatedBool

True if the request contains valid authentication header

Print PDF

Print PDF

 /printer/pdf/{model}/{id}
Parameters
Name Type Description
modelString [1:]

Record model

idString [1:]

Record ID

Print Personal Data PDF

 /printer/pdf/personal/{model}/{id}
Parameters
Name Type Description
modelString [1:]

Record model

idString [1:]

Record ID

Audit

Get list of audit logs

 /audit/{model}

Retrieve list of audit logs belonging to specified model

Parameters
Name Type Description
modelString [1:]

Model to query

offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
recordsArray

Array of retrieved records

↳[n]Object
total_resultsInt

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

Parameters
Name Type Description
modelString [1:]

Model to query

idString [1:]

Parent Record ID (audited record ID)

offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
recordsArray

Array of retrieved records

↳[n]Object
total_resultsInt

Total number of results, without taking offset and limit

Reports

Get list of reports

 /reports/{model}

Retrieve list of reports belonging to specified model

Parameters
Name Type Description
modelString [1:]

Model to query

offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
recordsArray

Array of retrieved records

↳[n]Object
total_resultsInt

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

Parameters
Name Type Description
modelString [1:]

Model to query

idString [1:]

Report ID

offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
recordsArray

Array of retrieved records

↳[n]Object
total_resultsInt

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

Parameters
Name Type Description
modelString [1:]

Model to query

idString [1:]

Run ID

offsetInt [0:] (0)

Offset in the list to start retrieval from

limitInt [1:200] (20)

Limits number of records returned

Return
Name Type Description
recordsArray

Array of retrieved records

↳[n]Object
total_resultsInt

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

Parameters
Name Type Description
modelString [1:]

Model

layoutString [1:]

New selected ListView layout(tab)

filter_layoutString [1:]

Filters form layout

filter_valuesArray

Array of list filters values

offsetInt [0:] (0)

ListView offset value

limitInt [1:200] (20)

ListView limit - number of records returned

order_byString

Sort order

Return
Name Type Description
return