LianaCMS REST API

Contacts

Serverhttps://example.lianacms.com/api/v3

Contacts of the contacts module, with their names, categories, links and properties.


Create contacts in a batch

POST
https://example.lianacms.com/api/v3
/batch/contacts
  • The body is a JSON array of contacts; an empty body returns 400. The contacts are processed by a background job: the response is 202 with href pointing to /job_queue/{job-queue-id}. Poll it; when the job is done it redirects to /batch/contacts/{job-queue-id}, which lists the rejected elements.
  • Each element is validated as in POST /contacts.
  • Unknown fields make an element invalid (the single-item endpoints ignore them). Invalid elements are skipped and the valid ones are written. If no element is valid, the whole job fails with message Invalid request body.
  • The rights are checked again when the job runs; if they are missing then, the job fails.
  • No limit on the number of elements is enforced.
  • Requires the Contacts module to be enabled, otherwise 403.
  • Requires the contacts_modify or contacts_import permission or membership in group 1, otherwise 403.

Create contacts in a batch › Request Body

oneOf
Exactly one variant must match.

Decision Table

VariantMatching Criteria
type = object · requires: firstname, lastname, categories
type = object · requires: type, names, categories
Properties for Variant 1:
firstname
​string · required

Person contacts only; ignored for organizations.

Example: John
lastname
​string · required

Person contacts only; ignored for organizations.

Example: Tester
categories
​integer[] · minItems: 1 · required

Ids of contact categories (under the contacts root category) on which the caller's group has admin rights, with the categories right. Any other id returns 400. In PATCH the list replaces the categories and the property values of removed categories are deleted; an empty list is ignored.

Example: [3,4]
type
​string · enum
Enum values:
person
Default: person
owner
​integer

Id of an existing user who is not deleted. Defaults to the caller when a contact is created.

Example: 54
valid_from
​string · date-time

ISO 8601. Must not be later than valid_to when both are given.

Example: 2045-02-04T05:24:28+02:00
valid_to
​string · date-time

ISO 8601.

Example: 2050-02-04T05:24:28+02:00
visibility
​VisibilityTypes · enum
Enum values:
public
private
registered
hidden
Default: public
​ContactProperties[]

Property values to set. Each entry replaces the values of that property in that language. The property must belong to a category of the contact. In PATCH null deletes every property value of the contact. Values of keyvalue properties cannot be written.

Create contacts in a batch › Responses

Accepted. The job was started; href is the job queue URL to poll.

The job that was started. `href` is the job queue resource (/job_queue/{job-queue-id}) to poll for its progress.
href
​string
​object
​Meta

Update contacts in a batch

PATCH
https://example.lianacms.com/api/v3
/batch/contacts
  • The body is a JSON array of contacts; an empty body returns 400. The contacts are processed by a background job: the response is 202 with href pointing to /job_queue/{job-queue-id}. Poll it; when the job is done it redirects to /batch/contacts/{job-queue-id}, which lists the rejected elements.
  • Each element needs id and is validated as in PATCH /contacts/{contact-id}. An id that does not exist, a contact the user has no rights to, or an id repeated within the batch makes the element invalid.
  • Unknown fields make an element invalid (the single-item endpoints ignore them). Invalid elements are skipped and the valid ones are written. If no element is valid, the whole job fails with message Invalid request body.
  • The rights are checked again when the job runs; if they are missing then, the job fails.
  • No limit on the number of elements is enforced.
  • Requires the Contacts module to be enabled, otherwise 403.
  • Requires the contacts_modify or contacts_import permission or membership in group 1, otherwise 403.

Update contacts in a batch › Request Body

Fields of `PATCH /contacts/{contact-id}` plus the required `id`. Person fields (firstname, lastname) and organization fields (names) depend on the contact's type.
id
​integer · int64 · required
anyOf
At least one variant must match. Multiple variants may match simultaneously.

Decision Table

VariantMatching Criteria
type = object
type = object
Properties for Variant 1:
firstname
​string

Person contacts only; ignored for organizations.

Example: John
lastname
​string

Person contacts only; ignored for organizations.

Example: Tester
type
​string · enum
Enum values:
person
Default: person
owner
​integer

Id of an existing user who is not deleted. Defaults to the caller when a contact is created.

Example: 54
valid_from
​string · date-time

ISO 8601. Must not be later than valid_to when both are given.

Example: 2045-02-04T05:24:28+02:00
valid_to
​string · date-time

ISO 8601.

Example: 2050-02-04T05:24:28+02:00
visibility
​VisibilityTypes · enum
Enum values:
public
private
registered
hidden
Default: public
categories
​integer[] · minItems: 1

Ids of contact categories (under the contacts root category) on which the caller's group has admin rights, with the categories right. Any other id returns 400. In PATCH the list replaces the categories and the property values of removed categories are deleted; an empty list is ignored.

Example: [3,4]
​ContactProperties[]

Property values to set. Each entry replaces the values of that property in that language. The property must belong to a category of the contact. In PATCH null deletes every property value of the contact. Values of keyvalue properties cannot be written.

Update contacts in a batch › Responses

Accepted. The job was started; href is the job queue URL to poll.

The job that was started. `href` is the job queue resource (/job_queue/{job-queue-id}) to poll for its progress.
href
​string
​object
​Meta

Get the result of a contacts batch job

GET
https://example.lianacms.com/api/v3
/batch/contacts/{job-queue-id}

Returns the outcome of a batch job started with POST or PATCH /batch/contacts, always with status 200.

  • When the job has completed, items lists the rejected elements as they were given (the fields password, unhashed_password, ssn and iban are replaced with [REDACTED]) and errors says why each was rejected, in the same order. Both are empty arrays when every element was written.
  • When the whole job failed, status is given instead, with state failed, the reason in message and the per-element errors.
  • A job with a status but not yet completed gives status with state processing. Batch jobs write their status only when they finish, so a running job is not found yet (404).
  • An id that is not 1 to 64 letters, digits, _ or - returns 400. An unknown job, one whose status is older than 24 hours, or a job of another batch resource returns 404.
  • Requires the Contacts module to be enabled, otherwise 403. No other permission is checked, and the job does not have to be the user's own.

Get the result of a contacts batch job › path Parameters

job-queue-id
​string · pattern: ^[A-Za-z0-9_-]{1,64}… · required

Id of the job, as given in the href of the POST or PATCH response: 1 to 64 letters, digits, _ or -. Any other id returns 400.

Get the result of a contacts batch job › Responses

OK

href
​string
​object[]

Why each rejected element was rejected, in the same order as items.

Present instead of items while the job is processing (state 'processing', without errors) or when the whole job failed (state 'failed', with message and errors). Both are returned with HTTP 200.

​Meta

List contacts

GET
https://example.lianacms.com/api/v3
/contacts

Returns contacts, highest id first. The caller needs the contacts_view or contacts_import right and sees the contacts in categories its groups have view rights to; members of group 1 have no exemption. Property values are included only with show_properties=true. The whole Contacts resource returns 403 when the contact finder module is not enabled, and PUT returns 403.

List contacts › query Parameters

limit
​integer · min: 0 · max: 200

The number of items to return, 0 to 200. A value outside that range returns 400.

Default: 20
offset
​integer · min: 0

The number of items to skip. A negative value is treated as 0. Use the next and prev links of the response to page through a list.

Default: 0
langcode[]
​string[] · minItems: 1 · style: form · explode: true

Return only contacts that have a name in one of these languages, and limit properties to them. Codes are checked against the site languages without regard to case (another code returns 400), but matched against the stored names exactly, so use upper case, e.g. langcode[]=FI&langcode[]=EN. Without the brackets the request returns 400.

categories[]
​integer[] · minItems: 1 · style: form · explode: true

Return only contacts in at least one of these categories, e.g. categories[]=1&categories[]=2. Each id must be a contact category the caller may write to (admin rights on it and the categories right), otherwise 400. Without the brackets the request returns 400.

visibility[]
​string[] · minItems: 1 · style: form · explode: true

Return only contacts with one of these visibilities, e.g. visibility[]=hidden&visibility[]=public. Another value, or a missing pair of brackets, returns 400.

Enum values:
public
private
registered
hidden
owner[]
​integer[] · minItems: 1 · style: form · explode: true

Return only contacts owned by one of these users, e.g. owner[]=1&owner[]=2. A value that is not an integer, or a missing pair of brackets, returns 400.

valid_from
​string · date-time

Return only contacts whose validity start exactly matches the given ISO 8601 date-time, e.g. valid_from=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

valid_from_before
​string · date-time

Return only contacts whose validity start is before the given ISO 8601 date-time, e.g. valid_from_before=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

valid_from_after
​string · date-time

Return only contacts whose validity start is after the given ISO 8601 date-time, e.g. valid_from_after=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

valid_to
​string · date-time

Return only contacts whose validity end exactly matches the given ISO 8601 date-time, e.g. valid_to=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

valid_to_before
​string · date-time

Return only contacts whose validity end is before the given ISO 8601 date-time, e.g. valid_to_before=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

valid_to_after
​string · date-time

Return only contacts whose validity end is after the given ISO 8601 date-time, e.g. valid_to_after=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

posted
​string · date-time

Return only contacts whose posting time exactly matches the given ISO 8601 date-time, e.g. posted=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

posted_before
​string · date-time

Return only contacts whose posting time is before the given ISO 8601 date-time, e.g. posted_before=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

posted_after
​string · date-time

Return only contacts whose posting time is after the given ISO 8601 date-time, e.g. posted_after=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

modified
​string · date-time

Return only contacts whose modification time exactly matches the given ISO 8601 date-time, e.g. modified=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

modified_before
​string · date-time

Return only contacts whose modification time is before the given ISO 8601 date-time, e.g. modified_before=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

modified_after
​string · date-time

Return only contacts whose modification time is after the given ISO 8601 date-time, e.g. modified_after=2019-12-13T10:47:00Z. A value that is not ISO 8601 returns 400.

show_properties
​boolean

true adds properties to every item of the list; any other value is ignored. The single-contact operations always return properties.

Default: false

List contacts › Responses

OK

Links of a list response. There is no `last` link and no total count.
href
​string
​object

First page.

​object

Previous page; the offset stops at 0.

​object

Next page. On the last page the link wraps around to offset 0.

​Meta

Create a contact

POST
https://example.lianacms.com/api/v3
/contacts

Creates a contact and returns it in items, with its new public addresses in links. Requires the contacts_import right or membership in group 1, otherwise 403. Returns 400 when categories are missing or not writable, a person lacks firstname or lastname, an organization lacks names, a names key or property langcode is not a site language, type or visibility has another value, owner is not an existing user, valid_from is later than valid_to, a date is not ISO 8601, or a property value does not fit the property.

Create a contact › Request Body

oneOf
Exactly one variant must match.

Decision Table

VariantMatching Criteria
type = object · requires: firstname, lastname, categories
type = object · requires: type, names, categories
Properties for Variant 1:
firstname
​string · required

Person contacts only; ignored for organizations.

Example: John
lastname
​string · required

Person contacts only; ignored for organizations.

Example: Tester
categories
​integer[] · minItems: 1 · required

Ids of contact categories (under the contacts root category) on which the caller's group has admin rights, with the categories right. Any other id returns 400. In PATCH the list replaces the categories and the property values of removed categories are deleted; an empty list is ignored.

Example: [3,4]
type
​string · enum
Enum values:
person
Default: person
owner
​integer

Id of an existing user who is not deleted. Defaults to the caller when a contact is created.

Example: 54
valid_from
​string · date-time

ISO 8601. Must not be later than valid_to when both are given.

Example: 2045-02-04T05:24:28+02:00
valid_to
​string · date-time

ISO 8601.

Example: 2050-02-04T05:24:28+02:00
visibility
​VisibilityTypes · enum
Enum values:
public
private
registered
hidden
Default: public
​ContactProperties[]

Property values to set. Each entry replaces the values of that property in that language. The property must belong to a category of the contact. In PATCH null deletes every property value of the contact. Values of keyvalue properties cannot be written.

Create a contact › Responses

OK

href
​string
​Meta

Get a contact

GET
https://example.lianacms.com/api/v3
/contacts/{contact-id}

Returns one contact in items, property values included. A contact the caller may not view (see List contacts) or that does not exist returns 404; an id that is not a positive integer returns 400.

Get a contact › path Parameters

contact-id
​integer · min: 1 · required

Id of the contact.

Get a contact › Responses

OK

href
​string
​Meta

Update a contact

PATCH
https://example.lianacms.com/api/v3
/contacts/{contact-id}

Changes the given fields and returns the contact in items; links is rebuilt when a name changes. Requires the contacts_import right or membership in group 1, otherwise 403, and a contact the caller may view, otherwise 404. Returns 400 for the validation errors of Create a contact and for a body with nothing to change.

Update a contact › path Parameters

contact-id
​integer · min: 1 · required

Id of the contact.

Update a contact › Request Body

All fields are optional. Giving `type` changes the type: changing to person needs firstname and lastname, and type organization always needs names. Without `type`, firstname and lastname apply to a person and names to an organization; fields of the other type are ignored, and a body left with nothing to change returns 400. `modified` is set to the current time; `modified_by` does not change.
type
​Types · enum
Enum values:
person
organization
Default: person
firstname
​string
lastname
​string
​names

Organization contacts only; ignored for persons, whose name is lastname firstname in every site language. Keys are site language codes (any other key returns 400). In PATCH an empty string removes the name in that language.

Example: {"FI":"Yritys Oy","EN":"Company Ltd"}
owner
​owner

Id of an existing user who is not deleted. Defaults to the caller when a contact is created.

Example: 54
valid_from
​valid_from · date-time

ISO 8601. Must not be later than valid_to when both are given.

Example: 2045-02-04T05:24:28+02:00
valid_to
​valid_to · date-time

ISO 8601.

Example: 2050-02-04T05:24:28+02:00
visibility
​VisibilityTypes · enum
Enum values:
public
private
registered
hidden
Default: public
categories
​integer[] · minItems: 1

Ids of contact categories (under the contacts root category) on which the caller's group has admin rights, with the categories right. Any other id returns 400. In PATCH the list replaces the categories and the property values of removed categories are deleted; an empty list is ignored.

Example: [3,4]
​array | null

Each entry replaces the values of that property in that language; null deletes every property value of the contact.

Update a contact › Responses

OK

href
​string
​Meta

Delete a contact

DELETE
https://example.lianacms.com/api/v3
/contacts/{contact-id}

Deletes the contact permanently and returns it as it was before the deletion. Requires the contacts_delete right or membership in group 1, otherwise 403, and a contact the caller may view, otherwise 404.

Delete a contact › path Parameters

contact-id
​integer · min: 1 · required

Id of the contact.

Delete a contact › Responses

OK

href
​string
​Meta