# google.appengine.api.datastore.AllocateIds

<br />

|---|
| [View source on GitHub](https://github.com/GoogleCloudPlatform/appengine-python-standard/tree/main/src/google/appengine/api/datastore.py#L2008-L2035) |

Allocates a range of `IDs` of size or with max for the given key.

    google.appengine.api.datastore.AllocateIds(
        model_key, size=None, **kwargs
    )

Allocates a range of `IDs` in the datastore such that those `IDs` will not
be automatically assigned to new entities. You can only allocate `IDs`
for model keys from your app. If there is an error, raises a subclass of
datastore_errors.Error.

Either size or max must be provided but not both. If size is provided then a
range of the given size is returned. If max is provided then the largest
range of ids that are safe to use with an upper bound of max is returned (can
be an empty range).

Max should only be provided if you have an existing numeric id range that you
want to reserve, e.g. bulk loading entities that already have `IDs`. If you
don't care about which `IDs` you receive, use size instead.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `model_key` | Key or string to serve as a model specifying the `ID` sequence in which to allocate `IDs` |
| `size` | integer, number of `IDs` to allocate. |
| `max` | integer, upper bound of the range of `IDs` to allocate. |
| `config` | Optional Configuration to use for this request. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| `(start, end)` of the allocated range, inclusive. ||

<br />