LianaCMS REST API

Users

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

CMS users. Listing and editing users needs user management rights; users outside them return 404.


List users

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

Returns users, highest id first. Deleted users and users signed in through secure LDAP are never listed. A caller outside group 1 sees the users that belong to at least one group its own groups manage, when its group has the users_view right and the managed group has rights to the current site; without any such group the list is empty. A member of group 1 sees every user who belongs to a group with rights to the current site. A group_id[] filter that names a group the caller may not view returns 400. Account module fields are returned when that module is enabled. Password hashes are never returned.

List users › 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
group_id[]
​integer[] · minItems: 1 · style: form · explode: true

Return only users who belong to at least one of these groups. Repeat the parameter for several ids, e.g. group_id[]=4&group_id[]=7; without the brackets the value is not an array and the request returns 400. A value that is not an integer, or a group the caller may not view, returns 400.

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

Return only users with one of these email addresses (exact, case-sensitive match). Repeat the parameter for several addresses, e.g. email[]=a@example.com&email[]=b@example.com; without the brackets the request returns 400.

List users › 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 user

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

Creates a user and returns it in items. If the request sent no password, the response has the generated one after active; a password you send is never returned. Every group in groups must exist and be one the caller may assign: a group that the caller's groups manage, when its group has the users_modify right and the managed group has rights to the current site. Group 1 can be assigned only by a member of group 1. Returns 400 when a required field is missing, a field has the wrong type, email is not a valid address, username is taken (compared without regard to case), groups names a group that does not exist or cannot be assigned, password is shorter than 8 bytes, sex is not m or f, or a date is not ISO 8601. Unknown fields are ignored.

Create a user › Request Body

Profile fields of the Account module. They are returned, and written, only when the Account module is enabled; otherwise they are accepted in requests but ignored. A field without a value is returned as null. In PATCH null clears a field; POST refuses null.
groups
​integer[] · minItems: 1 · required

Ids of the groups the user is a member of. In a request every group must exist and be one the caller may assign (see Create a user). In PATCH the list replaces the memberships; an empty list is ignored. The user's primary group is set to the first group listed.

Example: [3,5]
username
​string · required

Unique, compared without regard to case.

Example: user21
email
​string · required

Must be a valid email address. Uniqueness is not checked.

Example: john.tester@example.com
name
​string · required

Display name.

Example: John Tester
active
​boolean

Defaults to true when a user is created.

Example: true
valid_to
​string | null · date-time

Expiry time of the account. Takes ISO 8601 (a date alone is accepted). Null clears it in PATCH; POST refuses null.

Example: 2045-02-04T05:24:28+02:00
password
​string · minLength: 8

Plaintext password, at least 8 bytes. It is stored only as a hash and never returned. When a user is created without one, the CMS generates a random 15-character password. Changing the password ends the user's sessions.

Example: correct-horse-battery
firstname
​string | null
lastname
​string | null
birthdate
​string | null · date-time

Takes ISO 8601 (a date alone is accepted); returned as a date-time.

Example: 1947-02-04T00:00:00+02:00
city
​string | null
address1
​string | null
address2
​string | null
address3
​string | null
address4
​string | null
postalcode
​string | null
description
​string | null
avatar
​string | null
extra1
​string | null
extra2
​string | null
extra3
​string | null
sex
​string | null · enum
Enum values:
m
f
Example: m
phone
​string | null
company_name
​string | null
company_code
​string | null
company_address
​string | null
company_city
​string | null
company_postalcode
​string | null
company_phone
​string | null
company_www
​string | null
company_field
​string | null
company_size
​string | null
company_state
​string | null
company_country
​string | null
some1
​string | null
some2
​string | null
some3
​string | null

Create a user › Responses

OK

href
​string
​UserSinglePOST[] · maxItems: 1
​Meta

Get a user

GET
https://example.lianacms.com/api/v3
/users/{user-id}

Returns one user in items; the item has no href. A caller outside group 1 needs the users_view right over at least one group of the user (see List users), otherwise 404. A user that does not exist, is deleted, signs in through secure LDAP or belongs to no group also returns 404. An id that is not a positive integer returns 400. Account module fields are returned when that module is enabled.

Get a user › path Parameters

user-id
​integer · min: 1 · required

Id of the user.

Get a user › Responses

OK

href
​string
​UserSingle[] · maxItems: 1
​Meta

Update a user

PATCH
https://example.lianacms.com/api/v3
/users/{user-id}

Changes the given fields and returns the user in items. password is never returned; a password change ends the user's sessions. groups replaces the memberships. The caller needs the users_modify right over at least one group of the user (members of group 1 are exempt from this part) and must manage every group of the user, where only a member of group 1 manages group 1; the caller's own account is exempt from the second rule. Otherwise, and for the same users as in Get a user, it returns 404. The validation errors of Create a user return 400 here too, as does a body with no known field.

Update a user › path Parameters

user-id
​integer · min: 1 · required

Id of the user.

Update a user › Request Body

All fields are optional, but a body with none of them returns 400.
groups
​integer[] · minItems: 1

Ids of the groups the user is a member of. In a request every group must exist and be one the caller may assign (see Create a user). In PATCH the list replaces the memberships; an empty list is ignored. The user's primary group is set to the first group listed.

Example: [3,5]
username
​string

Unique, compared without regard to case.

Example: user21
email
​string

Must be a valid email address. Uniqueness is not checked.

Example: john.tester@example.com
name
​string

Display name.

Example: John Tester
active
​boolean

Defaults to true when a user is created.

Example: true
valid_to
​string | null · date-time

Expiry time of the account. Takes ISO 8601 (a date alone is accepted). Null clears it in PATCH; POST refuses null.

Example: 2045-02-04T05:24:28+02:00
password
​string · minLength: 8

Plaintext password, at least 8 bytes. It is stored only as a hash and never returned. When a user is created without one, the CMS generates a random 15-character password. Changing the password ends the user's sessions.

Example: correct-horse-battery
firstname
​string | null
lastname
​string | null
birthdate
​string | null · date-time

Takes ISO 8601 (a date alone is accepted); returned as a date-time.

Example: 1947-02-04T00:00:00+02:00
city
​string | null
address1
​string | null
address2
​string | null
address3
​string | null
address4
​string | null
postalcode
​string | null
description
​string | null
avatar
​string | null
extra1
​string | null
extra2
​string | null
extra3
​string | null
sex
​string | null · enum
Enum values:
m
f
Example: m
phone
​string | null
company_name
​string | null
company_code
​string | null
company_address
​string | null
company_city
​string | null
company_postalcode
​string | null
company_phone
​string | null
company_www
​string | null
company_field
​string | null
company_size
​string | null
company_state
​string | null
company_country
​string | null
some1
​string | null
some2
​string | null
some3
​string | null

Update a user › Responses

OK

href
​string
​UserSingle[] · maxItems: 1
​Meta

Delete a user

DELETE
https://example.lianacms.com/api/v3
/users/{user-id}

Soft-deletes the user: username and email become deleted_{id}_{original value} and the user is marked deleted. The response holds the user as it was before the deletion, without password. The caller needs the users_delete right and the users_modify right over at least one group of the user (members of group 1 are exempt from the latter), must manage every group of the user, and may not delete itself or a member of group 1. Otherwise, and for the same users as in Get a user, it returns 404.

Delete a user › path Parameters

user-id
​integer · min: 1 · required

Id of the user.

Delete a user › Responses

OK

href
​string
​UserSingle[] · maxItems: 1
​Meta

Create users in a batch

POST
https://example.lianacms.com/api/v3
/batch/users
  • The body is a JSON array of users; an empty body returns 400. The users 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/users/{job-queue-id}, which lists the rejected elements.
  • Each element is validated as in POST /users; password is required, and a username repeated within the batch makes the later 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.
  • No module check.
  • Requires the users_modify permission in at least one group of this site, otherwise 403.

Create users in a batch › Request Body

Profile fields of the Account module. They are returned, and written, only when the Account module is enabled; otherwise they are accepted in requests but ignored. A field without a value is returned as null. In PATCH null clears a field; POST refuses null.
groups
​integer[] · minItems: 1 · required

Ids of the groups the user is a member of. In a request every group must exist and be one the caller may assign (see Create a user). In PATCH the list replaces the memberships; an empty list is ignored. The user's primary group is set to the first group listed.

Example: [3,5]
username
​string · required

Unique, compared without regard to case.

Example: user21
email
​string · required

Must be a valid email address. Uniqueness is not checked.

Example: john.tester@example.com
name
​string · required

Display name.

Example: John Tester
password
​string · minLength: 8 · required

Plaintext password, at least 8 bytes. It is stored only as a hash and never returned. When a user is created without one, the CMS generates a random 15-character password. Changing the password ends the user's sessions.

Example: correct-horse-battery
active
​boolean

Defaults to true when a user is created.

Example: true
valid_to
​string | null · date-time

Expiry time of the account. Takes ISO 8601 (a date alone is accepted). Null clears it in PATCH; POST refuses null.

Example: 2045-02-04T05:24:28+02:00
firstname
​string | null
lastname
​string | null
birthdate
​string | null · date-time

Takes ISO 8601 (a date alone is accepted); returned as a date-time.

Example: 1947-02-04T00:00:00+02:00
city
​string | null
address1
​string | null
address2
​string | null
address3
​string | null
address4
​string | null
postalcode
​string | null
description
​string | null
avatar
​string | null
extra1
​string | null
extra2
​string | null
extra3
​string | null
sex
​string | null · enum
Enum values:
m
f
Example: m
phone
​string | null
company_name
​string | null
company_code
​string | null
company_address
​string | null
company_city
​string | null
company_postalcode
​string | null
company_phone
​string | null
company_www
​string | null
company_field
​string | null
company_size
​string | null
company_state
​string | null
company_country
​string | null
some1
​string | null
some2
​string | null
some3
​string | null

Create users 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 users in a batch

PATCH
https://example.lianacms.com/api/v3
/batch/users
  • The body is a JSON array of users; an empty body returns 400. The users 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/users/{job-queue-id}, which lists the rejected elements.
  • Each element needs id and is validated as in PATCH /users/{user-id}. An id that does not exist, a user outside the groups the token user may manage, an id repeated within the batch, or a username 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.
  • No module check.
  • Requires the users_modify permission in at least one group of this site, otherwise 403.

Update users in a batch › Request Body

Profile fields of the Account module. They are returned, and written, only when the Account module is enabled; otherwise they are accepted in requests but ignored. A field without a value is returned as null. In PATCH null clears a field; POST refuses null.
id
​integer · int64 · required
groups
​integer[] · minItems: 1

Ids of the groups the user is a member of. In a request every group must exist and be one the caller may assign (see Create a user). In PATCH the list replaces the memberships; an empty list is ignored. The user's primary group is set to the first group listed.

Example: [3,5]
username
​string

Unique, compared without regard to case.

Example: user21
email
​string

Must be a valid email address. Uniqueness is not checked.

Example: john.tester@example.com
name
​string

Display name.

Example: John Tester
active
​boolean

Defaults to true when a user is created.

Example: true
valid_to
​string | null · date-time

Expiry time of the account. Takes ISO 8601 (a date alone is accepted). Null clears it in PATCH; POST refuses null.

Example: 2045-02-04T05:24:28+02:00
password
​string · minLength: 8

Plaintext password, at least 8 bytes. It is stored only as a hash and never returned. When a user is created without one, the CMS generates a random 15-character password. Changing the password ends the user's sessions.

Example: correct-horse-battery
firstname
​string | null
lastname
​string | null
birthdate
​string | null · date-time

Takes ISO 8601 (a date alone is accepted); returned as a date-time.

Example: 1947-02-04T00:00:00+02:00
city
​string | null
address1
​string | null
address2
​string | null
address3
​string | null
address4
​string | null
postalcode
​string | null
description
​string | null
avatar
​string | null
extra1
​string | null
extra2
​string | null
extra3
​string | null
sex
​string | null · enum
Enum values:
m
f
Example: m
phone
​string | null
company_name
​string | null
company_code
​string | null
company_address
​string | null
company_city
​string | null
company_postalcode
​string | null
company_phone
​string | null
company_www
​string | null
company_field
​string | null
company_size
​string | null
company_state
​string | null
company_country
​string | null
some1
​string | null
some2
​string | null
some3
​string | null

Update users 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 users batch job

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

Returns the outcome of a batch job started with POST or PATCH /batch/users, 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.
  • No module check. No other permission is checked, and the job does not have to be the user's own.

Get the result of a users 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 users 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