> ## Documentation Index
> Fetch the complete documentation index at: https://docs.routr.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Credentials resource

> Every field of the Credentials resource, in YAML and API form, for operators who set the usernames and passwords Agents, Peers, and Trunks authenticate with.

A Credentials resource is a username and password. Agents and Peers use one to authenticate with Routr, and Trunks use them for inbound and outbound authentication with a provider.

## Fields

| YAML field | API / SDK field | Type | Required | Default | Description |
| - | - | - | - | - | - |
| `metadata.name` | `name` | `string` | Yes | - | Friendly name. Up to 60 characters. |
| `spec.credentials.username` | `username` | `string` | Yes | - | Username used in SIP digest authentication. |
| `spec.credentials.password` | `password` | `string` | Yes | - | Password used in SIP digest authentication. |
| - | `extended` | `object` | No | - | Custom attributes. API only. |

## Referenced by

| Resource | Field |
| - | - |
| [Agent](/reference/resources/agents) | `credentialsRef` |
| [Peer](/reference/resources/peers) | `credentialsRef` |
| [Trunk](/reference/resources/trunks) | `inboundCredentialsRef` (YAML `spec.inbound.credentialsRef`) and `outboundCredentialsRef` (YAML `spec.outbound.credentialsRef`) |

## Constraints

* `name` is required and must be 1 to 60 characters.
* `username` is required and can't contain spaces. In YAML it must be 4 to 60 characters.
* `password` is required, up to 255 characters.
* Quote numeric values in YAML (`"1001"`, `"1234"`) so they parse as strings.
* Deleting Credentials clears the reference on any Agent, Peer, or Trunk that used it.

> [!NOTE]
>
> pgdata marks the password column for field-level encryption. Set `CLOAK_ENCRYPTION_KEY` on the API server to encrypt it at rest. See [Environment variables](/reference/environment-variables).

## YAML example

The following Credentials are used by Agent `1001`.

```yaml theme={null}
- apiVersion: v2beta1
  kind: Credentials
  ref: credentials-01
  metadata:
    name: Agent Credentials
  spec:
    credentials:
      username: "1001"
      password: "1234"
```

## rctl equivalent

Run the interactive create command and answer the prompts. The password prompt masks your input.

```bash theme={null}
rctl credentials create
```

See [`rctl credentials`](/reference/rctl#credentials) for the prompts and the other actions.

## SDK equivalent

The following call creates the same Credentials through the API.

```typescript theme={null}
await new SDK.Credentials({ endpoint: "localhost:51908", insecure: true }).createCredentials({
  name: "Agent Credentials",
  username: "1001",
  password: "1234"
})
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.