Codat.Platform.APIKeys (codat v1.0.0)

Copy Markdown View Source

Manage Codat API keys programmatically.

You can have up to 10 active keys. The last remaining key cannot be deleted. Keys are only shown in full at creation time — store them immediately.

Summary

Functions

Creates a new API key. The full key value is only visible in the response.

Deletes an API key by its ID.

Lists all API keys for the authenticated account.

Functions

create(client_or_body, body_or_opts \\ [])

@spec create(Codat.Client.t() | map(), map() | keyword()) ::
  {:ok, map()} | {:error, Codat.Error.t()}

Creates a new API key. The full key value is only visible in the response.

Example

{:ok, key} = Codat.Platform.APIKeys.create(client, %{name: "Production"})
key["apiKey"]  # store this immediately!

delete(client_or_id, id_or_opts \\ [])

@spec delete(Codat.Client.t() | String.t(), String.t() | keyword()) ::
  {:ok, nil} | {:error, Codat.Error.t()}

Deletes an API key by its ID.

Example

{:ok, nil} = Codat.Platform.APIKeys.delete(client, "key-id")

list(client_or_opts \\ [], opts \\ [])

@spec list(
  Codat.Client.t() | keyword(),
  keyword()
) :: {:ok, Codat.Pagination.t()} | {:error, Codat.Error.t()}

Lists all API keys for the authenticated account.

Example

{:ok, page} = Codat.Platform.APIKeys.list(client)