---
title: Temporary Credentials
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[R2](https://developers.cloudflare.com/api/go/resources/r2)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Temporary Credentials

##### [Create Temporary Access Credentials](https://developers.cloudflare.com/api/go/resources/r2/subresources/temporary_credentials/methods/create)

client.R2.TemporaryCredentials.New(ctx, params) (\*[TemporaryCredentialNewResponse](<https://developers.cloudflare.com/api/go/resources/r2#(resource)%20r2.temporary_credentials%20%3E%20(model)%20TemporaryCredentialNewResponse%20%3E%20(schema)>), error)

POST/accounts/{account\_id}/r2/temp-access-credentials

##### ModelsExpand Collapse

<details>

<summary>

type TemporaryCredential struct{…}

</summary>

Bucket string

Name of the R2 bucket.

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20bucket">Link to this property</a>

ParentAccessKeyID string

Access key ID of the parent R2 API token. The temporary credentials cannot exceed this token’s permissions.

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20parentAccessKeyId">Link to this property</a>

<details>

<summary>

Permission TemporaryCredentialPermission

Permissions allowed on the credentials.

</summary>

One of the following:

const TemporaryCredentialPermissionAdminReadWrite TemporaryCredentialPermission = "admin-read-write"

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20permission%20%3E%20(member)%200">Link to this property</a>

const TemporaryCredentialPermissionAdminReadOnly TemporaryCredentialPermission = "admin-read-only"

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20permission%20%3E%20(member)%201">Link to this property</a>

const TemporaryCredentialPermissionObjectReadWrite TemporaryCredentialPermission = "object-read-write"

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20permission%20%3E%20(member)%202">Link to this property</a>

const TemporaryCredentialPermissionObjectReadOnly TemporaryCredentialPermission = "object-read-only"

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20permission%20%3E%20(member)%203">Link to this property</a>

</details>

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20permission">Link to this property</a>

TTLSeconds float64

Lifetime of the temporary credentials in seconds, up to 604800 seconds (7 days).

maximum604800

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20ttlSeconds">Link to this property</a>

Objects \[]stringOptional

Optional object paths to scope the credentials to.

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20objects">Link to this property</a>

Prefixes \[]stringOptional

Optional prefix paths to scope the credentials to.

<a href="#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)%20%3E%20(property)%20prefixes">Link to this property</a>

</details>

[Link to this property](<#(resource)%20r2.temporary_credentials%20%3E%20(model)%20temporary_credential%20%3E%20(schema)>)