Contacts of the contacts module, with their names, categories, links and properties.
Create contacts in a batch
- 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
hrefpointing 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_modifyorcontacts_importpermission or membership in group 1, otherwise 403.
Create contacts in a batch › Request Body
Decision Table
| Variant | Matching Criteria |
|---|---|
| type = object · requires: firstname, lastname, categories | |
| type = object · requires: type, names, categories |
firstnamePerson contacts only; ignored for organizations.
lastnamePerson contacts only; ignored for organizations.
categoriesIds 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.
typeownerId of an existing user who is not deleted. Defaults to the caller when a contact is created.
valid_fromISO 8601. Must not be later than valid_to when both are given.
valid_toISO 8601.
visibilityProperty 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.
Update contacts in a batch
- 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
hrefpointing 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
idand is validated as inPATCH /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_modifyorcontacts_importpermission or membership in group 1, otherwise 403.
Update contacts in a batch › Request Body
idDecision Table
| Variant | Matching Criteria |
|---|---|
| type = object | |
| type = object |
firstnamePerson contacts only; ignored for organizations.
lastnamePerson contacts only; ignored for organizations.
typeownerId of an existing user who is not deleted. Defaults to the caller when a contact is created.
valid_fromISO 8601. Must not be later than valid_to when both are given.
valid_toISO 8601.
visibilitycategoriesIds 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.
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.
Get the result of a contacts batch job
Returns the outcome of a batch job started with POST or PATCH /batch/contacts, always with status 200.
- When the job has completed,
itemslists the rejected elements as they were given (the fieldspassword,unhashed_password,ssnandibanare replaced with[REDACTED]) anderrorssays why each was rejected, in the same order. Both are empty arrays when every element was written. - When the whole job failed,
statusis given instead, with statefailed, the reason inmessageand the per-elementerrors. - A job with a status but not yet completed gives
statuswith stateprocessing. 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.
path Parameters
job-queue-id^[A-Za-z0-9_-]{1,64}… · requiredId 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
hrefWhy 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.
List 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.
query Parameters
limitThe number of items to return, 0 to 200. A value outside that range returns 400.
offsetThe 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.
langcode[]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[]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[]Return only contacts with one of these visibilities, e.g. visibility[]=hidden&visibility[]=public. Another value, or a missing pair of brackets, returns 400.
owner[]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_fromReturn 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_beforeReturn 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_afterReturn 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_toReturn 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_beforeReturn 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_afterReturn 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.
postedReturn 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_beforeReturn 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_afterReturn 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.
modifiedReturn 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_beforeReturn 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_afterReturn 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_propertiestrue adds properties to every item of the list; any other value is ignored. The single-contact operations always return properties.
List contacts › Responses
OK
hrefFirst page.
Previous page; the offset stops at 0.
Next page. On the last page the link wraps around to offset 0.
Create a contact
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
Decision Table
| Variant | Matching Criteria |
|---|---|
| type = object · requires: firstname, lastname, categories | |
| type = object · requires: type, names, categories |
firstnamePerson contacts only; ignored for organizations.
lastnamePerson contacts only; ignored for organizations.
categoriesIds 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.
typeownerId of an existing user who is not deleted. Defaults to the caller when a contact is created.
valid_fromISO 8601. Must not be later than valid_to when both are given.
valid_toISO 8601.
visibilityProperty 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
Get a contact
Update a contact
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.
path Parameters
contact-idId of the contact.
Update a contact › Request Body
typefirstnamelastnameOrganization 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.
ownerId of an existing user who is not deleted. Defaults to the caller when a contact is created.
valid_fromISO 8601. Must not be later than valid_to when both are given.
valid_toISO 8601.
visibilitycategoriesIds 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.
Each entry replaces the values of that property in that language; null deletes every property value of the contact.
Update a contact › Responses
OK
Delete a contact
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.
path Parameters
contact-idId of the contact.
Delete a contact › Responses
OK