> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.crehana.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.crehana.com/_mcp/server.

# Dynamic Client Registration (RFC 7591)

POST https://www.crehana.com/api/v5/rest/auth/oauth2/register
Content-Type: application/json

Registers an OAuth client. Accepts an application/json body (the only OAuth endpoint that reads JSON). Registration is public but restricted: public clients only, loopback/HTTPS redirect URIs and a scope allowlist, returning invalid_client_metadata / invalid_redirect_uri on violations.

Reference: https://developer.crehana.com/api-reference/endpoints/o-auth-2/register

## Authentication

- `Api-Key` header (required) — API key of the organization. Always sent together with the `Secret-Access` header.

## Servers

- `https://www.crehana.com` (Production, default)
- `https://qa.creha.co` (QA)

## Request

### Body (application/json)

This endpoint expects an OAuthRegisterClientInput.

- `redirect_uris` (list of string, required) — Client redirect URIs
- `token_endpoint_auth_method` (string, optional, default: none) — Client authentication method at the token endpoint
- `grant_types` (list of string, optional) — Grant types the client will use
- `response_types` (list of string, optional) — Response types the client will use
- `client_name` (string, optional) — Human-readable client name
- `scope` (string, optional) — Space-separated requested scopes

## Response

### 201

Successful Response

- `client_id` (string, required)
- `redirect_uris` (list of string, required)
- `client_id_issued_at` (integer, optional)
- `grant_types` (list of string, optional)
- `response_types` (list of string, optional)
- `token_endpoint_auth_method` (string, optional)
- `scope` (string, optional)
- `client_name` (string, optional)
- `client_secret` (string, optional)

## Errors

### 400 Bad Request Error

Bad Request

- `error` (string, required) — OAuth error code (RFC 6749 §5.2)
- `error_description` (string, optional) — Human-readable error description
- `state` (string, optional) — State echoed back on the /authorize error path

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

- string
- integer

## Examples

**Request**

```json
{
  "redirect_uris": [
    "http://127.0.0.1/callback"
  ],
  "token_endpoint_auth_method": "none",
  "grant_types": [
    "authorization_code",
    "refresh_token"
  ],
  "response_types": [
    "code"
  ],
  "client_name": "Claude Code",
  "scope": "openid profile api-v5:read"
}
```

**Response**

```json
{
  "client_id": "s6BhdRkqt3",
  "redirect_uris": [
    "http://127.0.0.1/callback"
  ],
  "client_id_issued_at": 1924905600,
  "grant_types": [
    "authorization_code",
    "refresh_token"
  ],
  "response_types": [
    "code"
  ],
  "token_endpoint_auth_method": "none",
  "scope": "openid profile api-v5:read",
  "client_name": "Claude Code"
}
```

**SDK Code**

```python
import requests

url = "https://www.crehana.com/api/v5/rest/auth/oauth2/register"

payload = {
    "redirect_uris": ["http://127.0.0.1/callback"],
    "token_endpoint_auth_method": "none",
    "grant_types": ["authorization_code", "refresh_token"],
    "response_types": ["code"],
    "client_name": "Claude Code",
    "scope": "openid profile api-v5:read"
}
headers = {
    "Secret-Access": "Secret-Access",
    "Api-Key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://www.crehana.com/api/v5/rest/auth/oauth2/register';
const options = {
  method: 'POST',
  headers: {
    'Secret-Access': 'Secret-Access',
    'Api-Key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"redirect_uris":["http://127.0.0.1/callback"],"token_endpoint_auth_method":"none","grant_types":["authorization_code","refresh_token"],"response_types":["code"],"client_name":"Claude Code","scope":"openid profile api-v5:read"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://www.crehana.com/api/v5/rest/auth/oauth2/register"

	payload := strings.NewReader("{\n  \"redirect_uris\": [\n    \"http://127.0.0.1/callback\"\n  ],\n  \"token_endpoint_auth_method\": \"none\",\n  \"grant_types\": [\n    \"authorization_code\",\n    \"refresh_token\"\n  ],\n  \"response_types\": [\n    \"code\"\n  ],\n  \"client_name\": \"Claude Code\",\n  \"scope\": \"openid profile api-v5:read\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Secret-Access", "Secret-Access")
	req.Header.Add("Api-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://www.crehana.com/api/v5/rest/auth/oauth2/register")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Secret-Access"] = 'Secret-Access'
request["Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"redirect_uris\": [\n    \"http://127.0.0.1/callback\"\n  ],\n  \"token_endpoint_auth_method\": \"none\",\n  \"grant_types\": [\n    \"authorization_code\",\n    \"refresh_token\"\n  ],\n  \"response_types\": [\n    \"code\"\n  ],\n  \"client_name\": \"Claude Code\",\n  \"scope\": \"openid profile api-v5:read\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://www.crehana.com/api/v5/rest/auth/oauth2/register")
  .header("Secret-Access", "Secret-Access")
  .header("Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"redirect_uris\": [\n    \"http://127.0.0.1/callback\"\n  ],\n  \"token_endpoint_auth_method\": \"none\",\n  \"grant_types\": [\n    \"authorization_code\",\n    \"refresh_token\"\n  ],\n  \"response_types\": [\n    \"code\"\n  ],\n  \"client_name\": \"Claude Code\",\n  \"scope\": \"openid profile api-v5:read\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.crehana.com/api/v5/rest/auth/oauth2/register', [
  'body' => '{
  "redirect_uris": [
    "http://127.0.0.1/callback"
  ],
  "token_endpoint_auth_method": "none",
  "grant_types": [
    "authorization_code",
    "refresh_token"
  ],
  "response_types": [
    "code"
  ],
  "client_name": "Claude Code",
  "scope": "openid profile api-v5:read"
}',
  'headers' => [
    'Api-Key' => '<apiKey>',
    'Content-Type' => 'application/json',
    'Secret-Access' => 'Secret-Access',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://www.crehana.com/api/v5/rest/auth/oauth2/register");
var request = new RestRequest(Method.POST);
request.AddHeader("Secret-Access", "Secret-Access");
request.AddHeader("Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"redirect_uris\": [\n    \"http://127.0.0.1/callback\"\n  ],\n  \"token_endpoint_auth_method\": \"none\",\n  \"grant_types\": [\n    \"authorization_code\",\n    \"refresh_token\"\n  ],\n  \"response_types\": [\n    \"code\"\n  ],\n  \"client_name\": \"Claude Code\",\n  \"scope\": \"openid profile api-v5:read\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Secret-Access": "Secret-Access",
  "Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "redirect_uris": ["http://127.0.0.1/callback"],
  "token_endpoint_auth_method": "none",
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"],
  "client_name": "Claude Code",
  "scope": "openid profile api-v5:read"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://www.crehana.com/api/v5/rest/auth/oauth2/register")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```