# CredentialStack

A named, ordered list of credentials a run may use (collection `credentialStack`). For each model call the entries are tried in order, skipping any whose rules or models don't fit the chosen model, and failing over to the next when one is rate-limited, failing or refused.

A run snapshots the stack when it starts (with `CredentialStack.Version`), so editing a stack never changes a run already going. Every entry names a credential in the stack's own tenant: that's checked when the stack is saved and again when it's resolved.

**Kind:** an object, used in responses.

## Fields

Every field is present in a response; empty ones are `null`.

| Field | Type | Description |
|---|---|---|
| `name` | `string` | Unique within the tenant; runs can name the stack instead of giving its id. |
| `description` | `string \| null` |  |
| `entries` | [`CredentialStackEntry`](https://docs.maitento.com/reference/types/credential-stack-entry.md)`[]` |  |
| `version` | `integer` | Goes up by one on every edit; a run records the version it snapshotted. |
| `externalTenantRef` | `string \| null` | The tenant in the calling system that owns this stack, as `<system>:<id>`; null when the owner isn't known (or the stack is shared). Set once, when the stack is created, and never changed. |
| `tenantId` | `uuid` | The id of the tenant it belongs to. |
| `id` | `uuid` | The unique id. Use it in `by-id` routes and wherever another object refers to this one. |
| `dateCreated` | `datetime` | When it was created, in UTC. |
| `dateUpdated` | `datetime` | When it was last changed, in UTC. |

## Example

```json
{
  "name": "...",
  "description": "...",
  "entries": [
    {
      "credentialId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
      "allowedModels": [],
      "allowedEndpointKinds": [],
      "enabled": false
    }
  ],
  "version": 0,
  "externalTenantRef": "...",
  "tenantId": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "id": "3f2b8c1e-5d4a-4e6b-9c7d-2a1b0c9d8e7f",
  "dateCreated": "2026-10-26T12:00:00.0000000Z",
  "dateUpdated": "2026-10-26T12:00:00.0000000Z"
}
```

## Where it's used

- [`credentialStacks.create`](https://docs.maitento.com/reference/api/credential-stacks.md) (`POST /credential-stacks`)
- [`credentialStacks.findByName`](https://docs.maitento.com/reference/api/credential-stacks.md) (`GET /credential-stacks/by-name/{name}`)
- [`credentialStacks.get`](https://docs.maitento.com/reference/api/credential-stacks.md) (`GET /credential-stacks/by-id/{id}`)
- [`credentialStacks.list`](https://docs.maitento.com/reference/api/credential-stacks.md) (`GET /credential-stacks`)
- [`credentialStacks.update`](https://docs.maitento.com/reference/api/credential-stacks.md) (`PUT /credential-stacks/by-id/{id}`)
