# Register a new OAuth client (third-party app)

`POST /api/oauth/clients`

Authentication: no security requirement declared for this operation.

Request body: application/json (required)

Type: object

Schema: [CreateOAuthClientDTO](https://sourcey-gauzy.pages.dev/api-reference/models/createoauthclientdto/index.md)

- `name` (required)
  Type: string
  
  maxLength: 100
  
  Example:
  
  ```json
  "Activepieces"
  ```

- `description` (optional)
  Type: string; nullable
  
  maxLength: 500

- `clientType` (optional)
  Type: string
  
  default: "confidential"
  
  enum: ["confidential","public"]

- `redirectUris` (required)
  Type: array
  
  Example:
  
  ```json
  [
    "https://cloud.activepieces.com/redirect"
  ]
  ```
  
  Items:
    Type: string

- `allowedScopes` (optional)
  Type: array
  
  Example:
  
  ```json
  [
    "profile",
    "email"
  ]
  ```
  
  Items:
    Type: string

- `allowedGrantTypes` (optional)
  Type: array
  
  default: ["authorization_code"]
  
  Items:
    Type: string
    
    enum: ["authorization_code","refresh_token","client_credentials"]

- `pkceRequired` (optional)
  Type: boolean
  
  default: false

- `accessTokenTtl` (optional)
  Type: number
  
  default: 86400
  
  minimum: 60
  
  maximum: 604800

- `refreshTokenTtl` (optional)
  Type: number
  
  default: 2592000
  
  minimum: 60
  
  maximum: 7776000

Responses:

- 201: Client created. The response includes the plaintext clientSecret exactly once — store it immediately.

- 400: Invalid input

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/oauth/clients' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "Activepieces",
  "description": "string",
  "clientType": "confidential",
  "redirectUris": [
    "https://cloud.activepieces.com/redirect"
  ],
  "allowedScopes": [
    "profile",
    "email"
  ],
  "allowedGrantTypes": [
    "authorization_code"
  ],
  "pkceRequired": false,
  "accessTokenTtl": 86400,
  "refreshTokenTtl": 2592000
}'
```

### JavaScript

```javascript
const body = `{
  "name": "Activepieces",
  "description": "string",
  "clientType": "confidential",
  "redirectUris": [
    "https://cloud.activepieces.com/redirect"
  ],
  "allowedScopes": [
    "profile",
    "email"
  ],
  "allowedGrantTypes": [
    "authorization_code"
  ],
  "pkceRequired": false,
  "accessTokenTtl": 86400,
  "refreshTokenTtl": 2592000
}`;

const response = await fetch('http://localhost:3000/api/oauth/clients', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "name": "Activepieces",
  "description": "string",
  "clientType": "confidential",
  "redirectUris": [
    "https://cloud.activepieces.com/redirect"
  ],
  "allowedScopes": [
    "profile",
    "email"
  ],
  "allowedGrantTypes": [
    "authorization_code"
  ],
  "pkceRequired": false,
  "accessTokenTtl": 86400,
  "refreshTokenTtl": 2592000
}'''

response = requests.post(
    'http://localhost:3000/api/oauth/clients',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
