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

# Create M2M client

POST https://app.kuudo.com/api/developers/m2m-clients
Content-Type: application/json

Creates an M2M client and returns HTTP 200 with its clientSecret. The secret is shown only once; store it securely. Scopes must be registered M2M scope IDs, and a bearer caller may grant only scopes its own token holds (403 PERMISSION_DENIED with details.exceedingScopes otherwise). New clients start in restricted authorization-access mode with no Amazon authorizations; authorization policy is managed in the dashboard. The organization's M2M client plan limit applies (403).

Requires every scope: `m2m-clients:write`.

Reference: https://docs.kuudo.com/api-reference/developer-credentials/create-m-2-m-client

## Authentication

- `Authorization` header (bearer token, required) — JWT returned by POST /api/auth/token-exchange. Amazon, authorization invitations, and developer credentials require API-key-derived tokens.

## Request

### Body (application/json)

This endpoint expects a M2MClientCreate.

- `name` (string, required)
- `scopes` (list of string, required) — Registered M2M scope IDs, no broader than the caller's own token scopes.
- `environment` (enum, required)
  - Allowed values: `production`, `development`
- `description` (string, optional)
- `expiry` (integer, optional) — Access JWT lifetime in seconds. Defaults to 900.

## Response

### 201

Created. clientSecret is returned only in this response.

- `m2mClient` (M2MClientCreated, required) — M2M client metadata. The client secret is never included.

## Errors

### 400 Bad Request Error

Invalid request or unsupported resource state.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 401 Unauthorized Error

Missing or invalid credentials, or inactive machine principal.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 403 Forbidden Error

Insufficient scope, authorization policy, or entitlement.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 500 Internal Server Error

Internal error.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

### 503 Service Unavailable Error

Dependency unavailable or application maintenance.

- `error` (ErrorError, required)
- `code` (string, optional)
- `details` (any, optional) — Endpoint-specific validation or failure details; shape varies.
- `requiredScopes` (list of string, optional)
- `errorCode` (string, optional)
- `message` (string, optional)
- `remediation` (string, optional)

## Types

### M2MClientCreated

M2M client metadata. The client secret is never included.

- `id` (integer, required) — Numeric ID used in /api/developers/m2m-clients/\{id}.
- `clientId` (string, required) — Client identifier used for token exchange.
- `name` (string, required)
- `scopes` (list of string, required)
- `environment` (enum, required)
  - Allowed values: `production`, `development`
- `tokenExpiry` (integer, required) — Lifetime in seconds of access JWTs exchanged for this client's keys.
- `status` (string, required)
- `createdAt` (datetime, required)
- `authorizationAccess` (M2MClientCreatedAuthorizationAccess, required) — Amazon authorization-access summary; managed in the dashboard.
- `clientSecret` (string, required) — Shown only once. Treat as a secret.
- `warning` (string, required)
- `description` (string, optional, nullable)
- `revokedAt` (datetime, optional, nullable)
- `revokedReason` (string, optional, nullable)

### ErrorError

- string
- ErrorError1

### M2MClientCreatedAuthorizationAccess

Amazon authorization-access summary; managed in the dashboard.

- `mode` (enum, required)
  - Allowed values: `restricted`, `organization_wide`
- `effectiveAuthorizationCount` (integer, required)
- `summary` (string, required)
- `needsConfiguration` (boolean, required)

### ErrorError1

- `code` (string, required)
- `message` (string, required)

## Examples

**Request**

```json
{
  "name": "Production integration",
  "scopes": [
    "servers:read"
  ],
  "environment": "production",
  "description": "Nightly sync worker",
  "expiry": 900
}
```

**Response**

```json
{
  "m2mClient": {
    "id": 1,
    "clientId": "string",
    "name": "string",
    "scopes": [
      "string"
    ],
    "environment": "production",
    "tokenExpiry": 1,
    "status": "string",
    "createdAt": "2024-01-15T09:30:00Z",
    "authorizationAccess": {
      "mode": "restricted",
      "effectiveAuthorizationCount": 1,
      "summary": "string",
      "needsConfiguration": true
    },
    "clientSecret": "string",
    "warning": "string",
    "description": "string",
    "revokedAt": "2024-01-15T09:30:00Z",
    "revokedReason": "string"
  }
}
```

**SDK Code**

```python Developer credentials_createM2MClient_example
import requests

url = "https://app.kuudo.com/api/developers/m2m-clients"

payload = {
    "name": "Production integration",
    "scopes": ["servers:read"],
    "environment": "production",
    "description": "Nightly sync worker",
    "expiry": 900
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Developer credentials_createM2MClient_example
const url = 'https://app.kuudo.com/api/developers/m2m-clients';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"name":"Production integration","scopes":["servers:read"],"environment":"production","description":"Nightly sync worker","expiry":900}'
};

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

```go Developer credentials_createM2MClient_example
package main

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

func main() {

	url := "https://app.kuudo.com/api/developers/m2m-clients"

	payload := strings.NewReader("{\n  \"name\": \"Production integration\",\n  \"scopes\": [\n    \"servers:read\"\n  ],\n  \"environment\": \"production\",\n  \"description\": \"Nightly sync worker\",\n  \"expiry\": 900\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 Developer credentials_createM2MClient_example
require 'uri'
require 'net/http'

url = URI("https://app.kuudo.com/api/developers/m2m-clients")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Production integration\",\n  \"scopes\": [\n    \"servers:read\"\n  ],\n  \"environment\": \"production\",\n  \"description\": \"Nightly sync worker\",\n  \"expiry\": 900\n}"

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

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

HttpResponse<String> response = Unirest.post("https://app.kuudo.com/api/developers/m2m-clients")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Production integration\",\n  \"scopes\": [\n    \"servers:read\"\n  ],\n  \"environment\": \"production\",\n  \"description\": \"Nightly sync worker\",\n  \"expiry\": 900\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.kuudo.com/api/developers/m2m-clients', [
  'body' => '{
  "name": "Production integration",
  "scopes": [
    "servers:read"
  ],
  "environment": "production",
  "description": "Nightly sync worker",
  "expiry": 900
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Developer credentials_createM2MClient_example
using RestSharp;

var client = new RestClient("https://app.kuudo.com/api/developers/m2m-clients");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Production integration\",\n  \"scopes\": [\n    \"servers:read\"\n  ],\n  \"environment\": \"production\",\n  \"description\": \"Nightly sync worker\",\n  \"expiry\": 900\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Developer credentials_createM2MClient_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "Production integration",
  "scopes": ["servers:read"],
  "environment": "production",
  "description": "Nightly sync worker",
  "expiry": 900
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://app.kuudo.com/api/developers/m2m-clients")! 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()
```