# Generate Database Credential

Launch stage: GA

`POST /api/2.0/postgres/credentials`

Generate OAuth credentials for a Postgres database.

API scopes: postgres

## Request body

- `claims` (array of object, optional)
  The returned token will be scoped to UC tables with the specified permissions.
  - `permission_set` (string, optional)
    Possible values: `PERMISSION_SET_UNSPECIFIED`, `READ_ONLY`
  - `resources` (array of object, optional)
    - `table_name` (string, required)
      The full Unity Catalog table name.
- `endpoint` (string, optional)
  The endpoint resource name for which this credential will be generated.
   Format: projects/{project_id}/branches/{branch_id}/endpoints/{endpoint_id}
  Example: `projects/my-project/branches/main/endpoints/my-endpoint`
- `ttl` (string, required)
  The requested time-to-live for the generated credential token.
   Must be at least 300 seconds (5 minutes) and at most 3600 seconds (1 hour).
- `expire_time` (string, required)
  Timestamp in UTC of when this credential should expire.
   Must be at least 300 seconds (5 minutes) and at most 1 hour from the current time.

## Returns

- `token` (string, optional)
  The OAuth token that can be used as a password when connecting to a database.
- `expire_time` (string, optional)
  Timestamp in UTC of when this credential expires.

## Response

```json
{
  "token": "string",
  "expire_time": "string"
}
```

