Reference documentation and code samples for the Cloud Firestore V1 Client class WriteRequest.
The request for Firestore.Write.
The first request creates a stream, or resumes an existing one from a token.
When creating a new stream, the server replies with a response containing
only an ID and a token, to use in the next request.
When resuming a stream, the server first streams any responses later than the
given token, then a response containing only an up-to-date token, to use in
the next request.
Generated from protobuf message google.firestore.v1.WriteRequest
Namespace
Google \ Cloud \ Firestore \ V1
Methods
__construct
Constructor.
Parameters
Name
Description
data
array
Optional. Data for populating the Message object.
↳ database
string
Required. The database name. In the format: projects/{project_id}/databases/{database_id}. This is only required in the first message.
↳ stream_id
string
The ID of the write stream to resume. This may only be set in the first message. When left empty, a new write stream will be created.
The writes to apply. Always executed atomically and in order. This must be empty on the first request. This may be empty on the last request. This must not be empty on all other requests.
↳ stream_token
string
A stream token that was previously sent by the server. The client should set this field to the token from the most recent WriteResponse it has received. This acknowledges that the client has received responses up to this token. After sending this token, earlier tokens may not be used anymore. The server may close the stream if there are too many unacknowledged responses. Leave this field unset when creating a new stream. To resume a stream at a specific point, set this field and the stream_id field. Leave this field unset when creating a new stream.
Required. The database name. In the format:
projects/{project_id}/databases/{database_id}.
This is only required in the first message.
Returns
Type
Description
string
setDatabase
Required. The database name. In the format:
projects/{project_id}/databases/{database_id}.
This is only required in the first message.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getStreamId
The ID of the write stream to resume.
This may only be set in the first message. When left empty, a new write
stream will be created.
Returns
Type
Description
string
setStreamId
The ID of the write stream to resume.
This may only be set in the first message. When left empty, a new write
stream will be created.
Parameter
Name
Description
var
string
Returns
Type
Description
$this
getWrites
The writes to apply.
Always executed atomically and in order.
This must be empty on the first request.
This may be empty on the last request.
This must not be empty on all other requests.
Always executed atomically and in order.
This must be empty on the first request.
This may be empty on the last request.
This must not be empty on all other requests.
A stream token that was previously sent by the server.
The client should set this field to the token from the most recent
WriteResponse it has received. This
acknowledges that the client has received responses up to this token. After
sending this token, earlier tokens may not be used anymore.
The server may close the stream if there are too many unacknowledged
responses.
Leave this field unset when creating a new stream. To resume a stream at
a specific point, set this field and the stream_id field.
Leave this field unset when creating a new stream.
Returns
Type
Description
string
setStreamToken
A stream token that was previously sent by the server.
The client should set this field to the token from the most recent
WriteResponse it has received. This
acknowledges that the client has received responses up to this token. After
sending this token, earlier tokens may not be used anymore.
The server may close the stream if there are too many unacknowledged
responses.
Leave this field unset when creating a new stream. To resume a stream at
a specific point, set this field and the stream_id field.
Leave this field unset when creating a new stream.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Cloud Firestore V1 Client - Class WriteRequest (1.53.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.53.0 (latest)](/php/docs/reference/cloud-firestore/latest/V1.WriteRequest)\n- [1.52.0](/php/docs/reference/cloud-firestore/1.52.0/V1.WriteRequest)\n- [1.51.0](/php/docs/reference/cloud-firestore/1.51.0/V1.WriteRequest)\n- [1.50.0](/php/docs/reference/cloud-firestore/1.50.0/V1.WriteRequest)\n- [1.48.1](/php/docs/reference/cloud-firestore/1.48.1/V1.WriteRequest)\n- [1.47.3](/php/docs/reference/cloud-firestore/1.47.3/V1.WriteRequest)\n- [1.46.0](/php/docs/reference/cloud-firestore/1.46.0/V1.WriteRequest)\n- [1.45.2](/php/docs/reference/cloud-firestore/1.45.2/V1.WriteRequest)\n- [1.44.1](/php/docs/reference/cloud-firestore/1.44.1/V1.WriteRequest)\n- [1.43.3](/php/docs/reference/cloud-firestore/1.43.3/V1.WriteRequest)\n- [1.40.0](/php/docs/reference/cloud-firestore/1.40.0/V1.WriteRequest)\n- [1.39.0](/php/docs/reference/cloud-firestore/1.39.0/V1.WriteRequest)\n- [1.38.0](/php/docs/reference/cloud-firestore/1.38.0/V1.WriteRequest)\n- [1.37.7](/php/docs/reference/cloud-firestore/1.37.7/V1.WriteRequest)\n- [1.36.1](/php/docs/reference/cloud-firestore/1.36.1/V1.WriteRequest)\n- [1.35.0](/php/docs/reference/cloud-firestore/1.35.0/V1.WriteRequest)\n- [1.34.0](/php/docs/reference/cloud-firestore/1.34.0/V1.WriteRequest)\n- [1.33.0](/php/docs/reference/cloud-firestore/1.33.0/V1.WriteRequest)\n- [1.32.0](/php/docs/reference/cloud-firestore/1.32.0/V1.WriteRequest)\n- [1.31.0](/php/docs/reference/cloud-firestore/1.31.0/V1.WriteRequest)\n- [1.30.0](/php/docs/reference/cloud-firestore/1.30.0/V1.WriteRequest)\n- [1.28.0](/php/docs/reference/cloud-firestore/1.28.0/V1.WriteRequest)\n- [1.27.3](/php/docs/reference/cloud-firestore/1.27.3/V1.WriteRequest) \nReference documentation and code samples for the Cloud Firestore V1 Client class WriteRequest.\n\nThe request for Firestore.Write.\n\nThe first request creates a stream, or resumes an existing one from a token.\nWhen creating a new stream, the server replies with a response containing\nonly an ID and a token, to use in the next request.\nWhen resuming a stream, the server first streams any responses later than the\ngiven token, then a response containing only an up-to-date token, to use in\nthe next request.\n\nGenerated from protobuf message `google.firestore.v1.WriteRequest`\n\nNamespace\n---------\n\nGoogle \\\\ Cloud \\\\ Firestore \\\\ V1\n\nMethods\n-------\n\n### __construct\n\nConstructor.\n\n### getDatabase\n\nRequired. The database name. In the format:\n`projects/{project_id}/databases/{database_id}`.\n\nThis is only required in the first message.\n\n### setDatabase\n\nRequired. The database name. In the format:\n`projects/{project_id}/databases/{database_id}`.\n\nThis is only required in the first message.\n\n### getStreamId\n\nThe ID of the write stream to resume.\n\nThis may only be set in the first message. When left empty, a new write\nstream will be created.\n\n### setStreamId\n\nThe ID of the write stream to resume.\n\nThis may only be set in the first message. When left empty, a new write\nstream will be created.\n\n### getWrites\n\nThe writes to apply.\n\nAlways executed atomically and in order.\nThis must be empty on the first request.\nThis may be empty on the last request.\nThis must not be empty on all other requests.\n\n### setWrites\n\nThe writes to apply.\n\nAlways executed atomically and in order.\nThis must be empty on the first request.\nThis may be empty on the last request.\nThis must not be empty on all other requests.\n\n### getStreamToken\n\nA stream token that was previously sent by the server.\n\nThe client should set this field to the token from the most recent\n[WriteResponse](/php/docs/reference/cloud-firestore/latest/V1.WriteResponse) it has received. This\nacknowledges that the client has received responses up to this token. After\nsending this token, earlier tokens may not be used anymore.\nThe server may close the stream if there are too many unacknowledged\nresponses.\nLeave this field unset when creating a new stream. To resume a stream at\na specific point, set this field and the `stream_id` field.\nLeave this field unset when creating a new stream.\n\n### setStreamToken\n\nA stream token that was previously sent by the server.\n\nThe client should set this field to the token from the most recent\n[WriteResponse](/php/docs/reference/cloud-firestore/latest/V1.WriteResponse) it has received. This\nacknowledges that the client has received responses up to this token. After\nsending this token, earlier tokens may not be used anymore.\nThe server may close the stream if there are too many unacknowledged\nresponses.\nLeave this field unset when creating a new stream. To resume a stream at\na specific point, set this field and the `stream_id` field.\nLeave this field unset when creating a new stream.\n\n### getLabels\n\nLabels associated with this write request.\n\n### setLabels\n\nLabels associated with this write request."]]