# Credentials

## Create Credential

**post** `/v5/credentials`

Create a new credential for storing sensitive data like API keys, tokens, or other secrets.

### Body Parameters

- `name: string`

  User-friendly name for the credential

- `payload: string`

  The credential payload to be encrypted

- `type: string`

  Type of credential: key or json

- `credential_metadata: optional map[unknown]`

  Optional unencrypted credential_metadata

- `description: optional string`

  Optional description

### Returns

- `Credential object { id, created_at, created_by_identity_type, 7 more }`

  - `id: string`

  - `created_at: string`

  - `created_by_identity_type: string`

  - `created_by_user_id: string`

  - `credential_metadata: map[unknown]`

  - `description: string`

  - `name: string`

  - `type: string`

  - `updated_at: string`

  - `object: optional string`

### Example

```http
curl https://api.egp.scale.com/v5/credentials \
    -H 'Content-Type: application/json' \
    -H "x-api-key: $SGP_API_KEY" \
    -d '{
          "name": "x",
          "payload": "x",
          "type": "x"
        }'
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by_identity_type": "created_by_identity_type",
  "created_by_user_id": "created_by_user_id",
  "credential_metadata": {
    "foo": "bar"
  },
  "description": "description",
  "name": "name",
  "type": "type",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "object": "object"
}
```

## Get Credential by ID

**get** `/v5/credentials/{credential_id}`

Retrieve a specific credential by its unique identifier.

### Path Parameters

- `credential_id: string`

### Returns

- `Credential object { id, created_at, created_by_identity_type, 7 more }`

  - `id: string`

  - `created_at: string`

  - `created_by_identity_type: string`

  - `created_by_user_id: string`

  - `credential_metadata: map[unknown]`

  - `description: string`

  - `name: string`

  - `type: string`

  - `updated_at: string`

  - `object: optional string`

### Example

```http
curl https://api.egp.scale.com/v5/credentials/$CREDENTIAL_ID \
    -H "x-api-key: $SGP_API_KEY"
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by_identity_type": "created_by_identity_type",
  "created_by_user_id": "created_by_user_id",
  "credential_metadata": {
    "foo": "bar"
  },
  "description": "description",
  "name": "name",
  "type": "type",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "object": "object"
}
```

## Get Credential by Name

**get** `/v5/credentials/name/{credential_name}`

Retrieve a specific credential by its name.

### Path Parameters

- `credential_name: string`

### Returns

- `Credential object { id, created_at, created_by_identity_type, 7 more }`

  - `id: string`

  - `created_at: string`

  - `created_by_identity_type: string`

  - `created_by_user_id: string`

  - `credential_metadata: map[unknown]`

  - `description: string`

  - `name: string`

  - `type: string`

  - `updated_at: string`

  - `object: optional string`

### Example

```http
curl https://api.egp.scale.com/v5/credentials/name/$CREDENTIAL_NAME \
    -H "x-api-key: $SGP_API_KEY"
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by_identity_type": "created_by_identity_type",
  "created_by_user_id": "created_by_user_id",
  "credential_metadata": {
    "foo": "bar"
  },
  "description": "description",
  "name": "name",
  "type": "type",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "object": "object"
}
```

## Get Credential Secret by ID

**post** `/v5/credentials/{credential_id}/secret`

Retrieve the plaintext payload of a credential by its ID.

### Path Parameters

- `credential_id: string`

### Returns

- `CredentialSecret object { result, object }`

  - `result: string`

  - `object: optional string`

### Example

```http
curl https://api.egp.scale.com/v5/credentials/$CREDENTIAL_ID/secret \
    -X POST \
    -H "x-api-key: $SGP_API_KEY"
```

#### Response

```json
{
  "result": "result",
  "object": "object"
}
```

## Get Credential Secret by Name

**post** `/v5/credentials/name/{credential_name}/secret`

Retrieve the plaintext payload of a credential by its name.

### Path Parameters

- `credential_name: string`

### Returns

- `CredentialSecret object { result, object }`

  - `result: string`

  - `object: optional string`

### Example

```http
curl https://api.egp.scale.com/v5/credentials/name/$CREDENTIAL_NAME/secret \
    -X POST \
    -H "x-api-key: $SGP_API_KEY"
```

#### Response

```json
{
  "result": "result",
  "object": "object"
}
```

## List Credentials

**get** `/v5/credentials`

Retrieve a paginated list of all credentials for the current account with optional name filtering.

### Query Parameters

- `ending_before: optional string`

- `limit: optional number`

- `name: optional string`

  Filter credentials by name

- `sort_by: optional string`

- `sort_order: optional SortOrder`

  - `"asc"`

  - `"desc"`

- `starting_after: optional string`

### Returns

- `has_more: boolean`

  Whether there are more items left to be fetched.

- `items: array of Credential`

  - `id: string`

  - `created_at: string`

  - `created_by_identity_type: string`

  - `created_by_user_id: string`

  - `credential_metadata: map[unknown]`

  - `description: string`

  - `name: string`

  - `type: string`

  - `updated_at: string`

  - `object: optional string`

- `total: number`

  The total of items that match the query. This is greater than or equal to the number of items returned.

- `limit: optional number`

  The maximum number of items to return.

- `object: optional "list"`

  - `"list"`

### Example

```http
curl https://api.egp.scale.com/v5/credentials \
    -H "x-api-key: $SGP_API_KEY"
```

#### Response

```json
{
  "has_more": true,
  "items": [
    {
      "id": "id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "created_by_identity_type": "created_by_identity_type",
      "created_by_user_id": "created_by_user_id",
      "credential_metadata": {
        "foo": "bar"
      },
      "description": "description",
      "name": "name",
      "type": "type",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "object": "object"
    }
  ],
  "total": 0,
  "limit": 0,
  "object": "list"
}
```

## Update Credential

**patch** `/v5/credentials/{credential_id}`

Update an existing credential's properties including name, description, type, payload, and metadata.

### Path Parameters

- `credential_id: string`

### Body Parameters

- `credential_metadata: optional map[unknown]`

  Optional unencrypted credential_metadata

- `description: optional string`

  Optional description

- `name: optional string`

  User-friendly name for the credential

- `payload: optional string`

  The credential payload to be encrypted

- `type: optional string`

  Type of credential: key or json

### Returns

- `Credential object { id, created_at, created_by_identity_type, 7 more }`

  - `id: string`

  - `created_at: string`

  - `created_by_identity_type: string`

  - `created_by_user_id: string`

  - `credential_metadata: map[unknown]`

  - `description: string`

  - `name: string`

  - `type: string`

  - `updated_at: string`

  - `object: optional string`

### Example

```http
curl https://api.egp.scale.com/v5/credentials/$CREDENTIAL_ID \
    -X PATCH \
    -H 'Content-Type: application/json' \
    -H "x-api-key: $SGP_API_KEY" \
    -d '{}'
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by_identity_type": "created_by_identity_type",
  "created_by_user_id": "created_by_user_id",
  "credential_metadata": {
    "foo": "bar"
  },
  "description": "description",
  "name": "name",
  "type": "type",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "object": "object"
}
```

## Delete Credential

**delete** `/v5/credentials/{credential_id}`

Permanently delete a credential and all its associated data.

### Path Parameters

- `credential_id: string`

### Returns

- `id: string`

- `deleted: boolean`

- `object: optional string`

### Example

```http
curl https://api.egp.scale.com/v5/credentials/$CREDENTIAL_ID \
    -X DELETE \
    -H "x-api-key: $SGP_API_KEY"
```

#### Response

```json
{
  "id": "id",
  "deleted": true,
  "object": "object"
}
```

## Domain Types

### Credential

- `Credential object { id, created_at, created_by_identity_type, 7 more }`

  - `id: string`

  - `created_at: string`

  - `created_by_identity_type: string`

  - `created_by_user_id: string`

  - `credential_metadata: map[unknown]`

  - `description: string`

  - `name: string`

  - `type: string`

  - `updated_at: string`

  - `object: optional string`

### Credential Secret

- `CredentialSecret object { result, object }`

  - `result: string`

  - `object: optional string`

### Credential Delete Response

- `CredentialDeleteResponse object { id, deleted, object }`

  - `id: string`

  - `deleted: boolean`

  - `object: optional string`
