Bulk create and update documents

post/documents/bulk
Internal-Use Only

Creates and updates internal documents in bulk. The input is a list of document objects. Each document represents either a Create or Update operation, depending on its form. The output is a list of operation summary results.

The input for the request is a SAS collection, which looks like the following:

{
  "items":[...]
}

Each element in "items" represents a series of records to be inserted or updated. If a given record includes a primary key, then it is treated as an update. Otherwise, it is a Create operation. All locks, unlocks, creates, and updates are processed internally by the server.

The response from the request is another SAS collection with summary results for each item that was sent. Result items are in the same order as the input collection. This is especially important if you need to capture the newly generated primary keys of values that were inserted. If there is a problem, there will be an "error" property in the results for the item that had issues. If some items return errors, it does not prevent other valid records from being successfully processed.

Request Samples

1

Response Samples

1{
2 "links": [],
3 "name": "entities",
4 "count": 1,
5 "items": [
6 {
7 "id": "uuid_100",
8 "entityType": "person",
9 "operation": "UPDATE"
10 }
11 ],
12 "version": 2
13}

Header Parameters

NameTypeRequiredDescription
Content-Item-Type
string
false

For document fields that use data masking, it is important to avoid accidentally overwriting values in the database with masked values that have been loaded by the client. In general, masking dots should not be stored in the database. The "Content-Item-Type" HTTP header can be used to control how masked fields are handled with bulk updates. If this HTTP header is not provided, then masked field values that are set to null will be ignored. If the "Content-Item-Type" header is set to "application/vnd.sas.investigation.data.masked.document+json" then masked fields that are set to the mask template (nine dots) will be ignored. The "Content-Item-Type" header value should match the data masking approach that was used to fetch data before an update is performed.

Allowed value:
application/vnd.sas.investigation.data.masked.document+json

Request Body

This is a base schema that is used to define paginated collections of resources. It is based on http://{SAS API Portal}/reference/schema/baseCollection/v2/baseCollection2.json. Other APIs can extend this base schema by adding an "items" array property.

NameTypeRequiredDescription
name
string
false

The name of the collection.

start
integer<int64>
false

The zero-based index of the first item in the collection.

limit
integer
false

The number of items that were requested for the collection.

count
integer<int64>
false

If populated, indicates the number of items in the collection.

accept
string
false

A space-delimited list of media types from which an Accept header can be constructed.

links
array [SAS Link]
false

The links that apply to the collection.

version
integer
false

The version number of the collection representation. This representation is version 2.

Responses

StatusMeaningDescription
201CreatedInternal documents were created or updated. See items in the collection to determine whether the operation for an individual document succeeded or failed. Schema
400Bad RequestThe request was invalid.Schema
415Unsupported Media TypeThe endpoint does not support collection items of the type specified in the `Content-Item-Type` request header. Schema