POST /api/v1/codes
Creates a new codes resource.
This endpoint documentation is generated from the current Fastify route implementation and should be treated as the implementation-level contract for this version of the API.
Source route file: src/api/routes/external/public/codes/post.ts
Request Method
POST
Base URL
https://api.userdocks.local:5000
Endpoint
/api/v1/codes
Path Variables
No path variables.
Query Parameters
No query parameters.
HTTP Headers
| Variable | Type | Required | Description |
|---|---|---|---|
Origin | string | false | Used for custom-domain lookup in public app resolution. |
Content-Type | string | true | Use application/json for JSON request bodies. |
Request Body
Schema reference: createCodeSchema
{
"appUuid": "11111111-1111-1111-1111-111111111111",
"email": "user@example.com",
"password": "VeryStrongPass123!",
"state": "state-from-client",
"redirectUri": "https://app.example.com/callback",
"acceptPrivacyPolicy": false
}
Successful Response
Success status code(s): 201.
{
"kind": "codes",
"totalItems": 1,
"itemsLength": 1,
"items": [
{
"nextAction": {
"action": "httpRequest",
"url": "https://app.example.com/callback?code=code_abc123&state=state_123&client_id=app_11111111-1111-1111-1111-111111111111&redirect_uri=https://app.example.com/callback&service=email&grant_type=authorization_code",
"method": "GET"
}
}
]
}
Error Responses
| HTTP Status | Example Error |
|---|---|
400 | {"errors":[{"validation":"error","code":"[E4000]","message":"Bad Request / validation error"}]} |
500 | {"errors":[{"validation":"error","code":"[E0000]","message":"Internal Server Error"}]} |
Example
const url = `https://api.userdocks.local:5000/api/v1/codes`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: '{"appUuid":"11111111-1111-1111-1111-111111111111","email":"user@example.com","password":"VeryStrongPass123!","state":"state-from-client","redirectUri":"https://app.example.com/callback","acceptPrivacyPolicy":false}',
});
const data = await response.json();
console.log(response.status, data);