---
search:
  tags:
    - OAuth applications
    - POST
seo:
  description: >-
    Requires organization:update; giving the application a Role… Reference for
    the POST /organizations/{organizationId}/oauth-clients endpoint in the Auth
    API.
sidebar:
  label: Create an OAuth application
  badge: POST
title: Create an OAuth application
type: openapi-operation
---
Requires organization:update; giving the application a Role that grants organization:delete also requires organization:delete. Unknown Role names and invalid keys are refused (400). With `secret`, the response holds the first client secret, which cannot be read again.

`POST /organizations/{organizationId}/oauth-clients`

**Request body** (`application/json`, required)

- `name` (string, required) — Trimmed; 1 to 100 characters.
- `scopes` (string[])
- `roles` (string[]) — Role names the client holds.
- `keys` (public_jwk[]) — Public keys to register; more can be added later.
- `secret` (boolean) — Create a first client secret, returned once in the response's secrets. A client needs a secret or a key to get tokens.
- `secret_expires_at` (string<date-time>) — The first secret's expiry, in the future; only with secret. Without it the secret does not expire.

Request body example:

```json
{
  "name": "string",
  "scopes": [
    "string"
  ],
  "roles": [
    "string"
  ],
  "keys": [
    {}
  ],
  "secret": true,
  "secret_expires_at": "2019-08-24T14:15:22Z"
}
```

**Responses**

- `201` — The created client.
- `default` — The request failed.

Response example, 201:

```json
{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "client_id": "string",
  "name": "string",
  "scopes": [
    "string"
  ],
  "roles": [
    "string"
  ],
  "keys": [
    {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "kid": "string",
      "jwk": {},
      "created_at": "2019-08-24T14:15:22Z",
      "revoked_at": "2019-08-24T14:15:22Z"
    }
  ],
  "secrets": [
    {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "secret": "string",
      "hint": "string",
      "created_at": "2019-08-24T14:15:22Z",
      "expires_at": "2019-08-24T14:15:22Z",
      "revoked_at": "2019-08-24T14:15:22Z"
    }
  ],
  "created_at": "2019-08-24T14:15:22Z",
  "updated_at": "2019-08-24T14:15:22Z",
  "revoked_at": "2019-08-24T14:15:22Z"
}
```
