---
title: "POST /v1/projects/{projectId}:allocateIds"
method: POST
path: "/v1/projects/{projectId}:allocateIds"
tags: ["projects"]
---

# POST /v1/projects/{projectId}:allocateIds

`POST /v1/projects/{projectId}:allocateIds`

Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.

## Path parameters

- `projectId` string, required

## Request body

- AllocateIdsRequest — The request for Datastore.AllocateIds.
  - `databaseId` string — The ID of the database against which to make the request. '(default)' is not allowed; please use empty string '' to refer the default database.
  - `keys` Key[] — Required. A list of keys with incomplete key paths for which to allocate IDs. No key may be reserved/read-only.
    - `partitionId` PartitionId — A partition ID identifies a grouping of entities. The grouping is always by project and namespace, however the namespace ID may be empty. A partition ID contains several dimensions: project ID and namespace ID. Partition dimensions: - May be `""`. - Must be valid UTF-8 bytes. - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}` If the value of any dimension matches regex `__.*__`, the partition is reserved/read-only. A reserved/read-only partition ID is forbidden in certain documented contexts. Foreign partition IDs (in which the project ID does not match the context project ID ) are discouraged. Reads and writes of foreign partition IDs may fail if the project is not in an active state.
      - `projectId` string — The ID of the project to which the entities belong.
      - `databaseId` string — If not empty, the ID of the database to which the entities belong.
      - `namespaceId` string — If not empty, the ID of the namespace to which the entities belong.
    - `path` PathElement[] — The entity path. An entity path consists of one or more elements composed of a kind and a string or numerical identifier, which identify entities. The first element identifies a _root entity_, the second element identifies a _child_ of the root entity, the third element identifies a child of the second entity, and so forth. The entities identified by all prefixes of the path are called the element's _ancestors_. An entity path is always fully complete: *all* of the entity's ancestors are required to be in the path along with the entity identifier itself. The only exception is that in some documented cases, the identifier in the last path element (for the entity) itself may be omitted. For example, the last path element of the key of `Mutation.insert` may have no identifier. A path can never be empty, and a path can have at most 100 elements.
      - `name` string — The name of the entity. A name matching regex `__.*__` is reserved/read-only. A name must not be more than 1500 bytes when UTF-8 encoded. Cannot be `""`. Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are encoded as `__bytes__` where `` is the base-64 encoding of the bytes.
      - `kind` string — The kind of the entity. A kind matching regex `__.*__` is reserved/read-only. A kind must not contain more than 1500 bytes when UTF-8 encoded. Cannot be `""`. Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are encoded as `__bytes__` where `` is the base-64 encoding of the bytes.
      - `id` string, int64 — The auto-allocated ID of the entity. Never equal to zero. Values less than zero are discouraged and may not be supported in the future.
  - `requestOptions` RequestOptions — Options for a request.
    - `requestTags` string[] — Optional. The request tags for the request. The tags are processed as follows: - Truncated to 510 characters. - Filtered out if empty. - Deduplicated. - Limited to 50 tags.

## Response `200`

Successful response

---

[API](https://skmtc.dev/google/apis/datastore.md) · [All operations](https://skmtc.dev/google/apis/datastore/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/google/datastore/revisions/aef4907227b2/schema)
