pydo.spaces_key.create()

Generated on 7 Jul 2026 from pydo version v0.39.0

Usage

client.spaces_key.create(
    body={
        "name": "my-access-key",
        "grants": [...],
    },
)
Returns JSONRaises HttpResponseError

Description

To create a new Spaces Access Key, send a POST request to /v2/spaces/keys. At the moment, you cannot mix a fullaccess permission with scoped permissions. A fullaccess permission will be prioritized if fullaccess and scoped permissions are both added.

Parameters

name string optional

Example: my-access-key

The access key's name.

grants array of objects optional

The list of permissions for the access key.

Default: []

Show child properties
bucket string required

Example: my-bucket

The name of the bucket.

permission string required

Example: read

The permission to grant to the user. Possible values are read, readwrite, fullaccess, or an empty string.

access_key string optional read-only

Example: DOACCESSKEYEXAMPLE

The Access Key ID used to access a bucket.

created_at string optional read-only

Example: 2018-07-19T15:04:16Z

The date and time the key was created.

Request Sample

Show Request Sample
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
  "name": "read-only-key",
  "grants": [
    {
      "bucket": "my-bucket",
      "permission": "read"
    }
  ]
}

resp = client.spaces_key.create(body=req)

Response Example

Show Response Example
{
  "key": {
    "name": "read-only-key",
    "access_key": "DOACCESSKEYEXAMPLE",
    "secret_key": "DOSECRETKEYEXAMPLE",
    "grants": [
      {
        "bucket": "my-bucket",
        "permission": "read"
      }
    ],
    "created_at": "2018-07-19T15:04:16Z"
  }
}

More Information

See /v2/spaces/keys in the API reference for additional detail on responses, headers, parameters, and more.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.