younifyd
Menu

Firestore.projects.databases.documents.batch Write

Applies a batch of write operations. The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the BatchWriteResponse for the success status of each write. If you require an atomically applied set of writes, use Commit instead.

POST/v1/{database}/documents:batchWrite

Use it in a workflow

  1. Add a step and choose the Firestore connector.
  2. Pick the Firestore.projects.databases.documents.batch Write action (under projects).
  3. Fill in the fields below, then reference the result from later steps as {{firestoreProjectsDatabasesDocumentsBatchWrite.response.data}}.

Request

Path parameters

databasestringrequired

Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`.

Query parameters

$.xgafvstring

V1 error format.

One of12

access_tokenstring

OAuth access token.

altstring

Data format for response.

One ofjsonmediaproto

callbackstring

JSONP

fieldsstring

Selector specifying which fields to include in a partial response.

keystring

API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.

oauth_tokenstring

OAuth 2.0 token for the current user.

prettyPrintboolean

Returns response with indentations and line breaks.

quotaUserstring

Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.

upload_protocolstring

Upload protocol for media (e.g. "raw", "multipart").

uploadTypestring

Legacy upload protocol for media (e.g. "media", "multipart").

Request body

Enter the body as JSON in the step's Body field.

labelsobject

Labels associated with this batch write.

writesarray<object>

The writes to apply. Method does not apply writes atomically and does not guarantee ordering. Each write succeeds or fails independently. You cannot write to the same document more than once per request.

currentDocumentobject2 fields

A precondition on a document, used for conditional operations.

deletestring

A document name to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`.

transformobject2 fields

A transformation of a document.

updateobject4 fields

A Firestore document. Must not exceed 1 MiB - 4 bytes.

updateMaskobject1 fields

A set of field paths on a document. Used to restrict a get or update operation on a document to a subset of its fields. This is different from standard field masks, as this is always scoped to a Document, and takes in account the dynamic nature of Value.

updateTransformsarray<object>7 fields

The transforms to perform after update. This field can be set only when the operation is `update`. If present, this write is equivalent to performing `update` and `transform` to the same document atomically and in order.

json
{
  "labels": {},
  "writes": [
    {
      "currentDocument": {
        "exists": false,
        "updateTime": "string"
      },
      "delete": "string",
      "transform": {
        "document": "string",
        "fieldTransforms": [
          {
            "appendMissingElements": {
              "values": null
            },
            "fieldPath": "string",
            "increment": {
              "arrayValue": null,
              "booleanValue": null,
              "bytesValue": null,
              "doubleValue": null,
              "geoPointValue": null,
              "integerValue": null,
              "mapValue": null,
              "nullValue": null,
              "referenceValue": null,
              "stringValue": null,
              "timestampValue": null
            },
            "maximum": {
              "arrayValue": null,
              "booleanValue": null,
              "bytesValue": null,
              "doubleValue": null,
              "geoPointValue": null,
              "integerValue": null,
              "mapValue": null,
              "nullValue": null,
              "referenceValue": null,
              "stringValue": null,
              "timestampValue": null
            },
            "minimum": {
              "arrayValue": null,
              "booleanValue": null,
              "bytesValue": null,
              "doubleValue": null,
              "geoPointValue": null,
              "integerValue": null,
              "mapValue": null,
              "nullValue": null,
              "referenceValue": null,
              "stringValue": null,
              "timestampValue": null
            },
            "removeAllFromArray": {
              "values": null
            },
            "setToServerValue": "SERVER_VALUE_UNSPECIFIED"
          }
        ]
      },
      "update": {
        "createTime": "string",
        "fields": {},
        "name": "string",
        "updateTime": "string"
      },
      "updateMask": {
        "fieldPaths": [
          "string"
        ]
      },
      "updateTransforms": [
        {
          "appendMissingElements": {
            "values": [
              null
            ]
          },
          "fieldPath": "string",
          "increment": {
            "arrayValue": {
              "values": null
            },
            "booleanValue": false,
            "bytesValue": "string",
            "doubleValue": 0,
            "geoPointValue": {
              "latitude": null,
              "longitude": null
            },
            "integerValue": "string",
            "mapValue": {
              "fields": null
            },
            "nullValue": "NULL_VALUE",
            "referenceValue": "string",
            "stringValue": "string",
            "timestampValue": "string"
          },
          "maximum": {
            "arrayValue": {
              "values": null
            },
            "booleanValue": false,
            "bytesValue": "string",
            "doubleValue": 0,
            "geoPointValue": {
              "latitude": null,
              "longitude": null
            },
            "integerValue": "string",
            "mapValue": {
              "fields": null
            },
            "nullValue": "NULL_VALUE",
            "referenceValue": "string",
            "stringValue": "string",
            "timestampValue": "string"
          },
          "minimum": {
            "arrayValue": {
              "values": null
            },
            "booleanValue": false,
            "bytesValue": "string",
            "doubleValue": 0,
            "geoPointValue": {
              "latitude": null,
              "longitude": null
            },
            "integerValue": "string",
            "mapValue": {
              "fields": null
            },
            "nullValue": "NULL_VALUE",
            "referenceValue": "string",
            "stringValue": "string",
            "timestampValue": "string"
          },
          "removeAllFromArray": {
            "values": [
              null
            ]
          },
          "setToServerValue": "SERVER_VALUE_UNSPECIFIED"
        }
      ]
    }
  ]
}

Response

Returns 200 with an object. Read it in later steps with {{firestoreProjectsDatabasesDocumentsBatchWrite.response.data.<field>}}.

statusarray<object>

The status of applying the writes. This i-th write status corresponds to the i-th write in the request.

codeinteger (int32)

The status code, which should be an enum value of google.rpc.Code.

detailsarray<object>

A list of messages that carry the error details. There is a common set of message types for APIs to use.

messagestring

A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.

writeResultsarray<object>

The result of applying the writes. This i-th write result corresponds to the i-th write in the request.

transformResultsarray<object>11 fields

The results of applying each DocumentTransform.FieldTransform, in the same order.

updateTimestring (google-datetime)

The last update time of the document after applying the write. Not set after a `delete`. If the write did not actually change the document, this will be the previous update_time.

json
{
  "status": [
    {
      "code": 0,
      "details": [
        {}
      ],
      "message": "string"
    }
  ],
  "writeResults": [
    {
      "transformResults": [
        {
          "arrayValue": {
            "values": [
              null
            ]
          },
          "booleanValue": false,
          "bytesValue": "string",
          "doubleValue": 0,
          "geoPointValue": {
            "latitude": 0,
            "longitude": 0
          },
          "integerValue": "string",
          "mapValue": {
            "fields": {}
          },
          "nullValue": "NULL_VALUE",
          "referenceValue": "string",
          "stringValue": "string",
          "timestampValue": "string"
        }
      ],
      "updateTime": "string"
    }
  ]
}

Need more? See the Firestore guide for connection setup and behaviour shared by every action.