Post consumer session
In order to use the API's protected endpoints, a new session MUST be established for the service consumer. To do this, a valid Api-Key in the HTTP request headers together with the data type: session in the JSON request body MUST be sent.
A data attributes note for the session MAY be sent in the JSON request body. The data attributes path is REQUIRED in the JSON request body, even if it is empty.
The identifier of the new session object is returned from the remote service in the JSON response body as data id together with other attribute–value pairs.
The identifier of the session object MUST be sent as Session-Key to the remote service in the HTTP request headers of all subsequent requests of the established session and SHOULD be revoked if the session object has fulfilled its purpose.
Request endpoint
POST SERVER:PORT/api/sessions
Response status
201
Request headers
Accept:application/vnd.api+json
Content-Type:application/vnd.api+json
Api-Key:KKKKKKKK-KKKK-KKKK-KKKK-KKKKKKKKKKKK
Response headers
Transfer-Encoding:chunked
Connection:keep-alive
Accept:application/vnd.api+json
Cache-Control:no-cache
Date:Tue, 19 Mar 2024 12:52:00 GMT
Content-Type:application/vnd.api+json
Server:nginx/1.25.4
Request body
{
"data": {
"attributes": {
"note": "A session note"
},
"type": "session"
}
}
Response body
{
"links": {
"self": "/api/sessions"
},
"data": {
"attributes": {
"note": "A session note",
"client": "172.18.0.1",
"agent": "HTTP.jl/1.8.5",
"timestamps": {
"granted": "2024-03-19T12:52:00.266Z"
},
"limits": {
"maxTokens": 100000,
"maxDigits": 100,
"minTokens": 1000,
"minDigits": 3
}
},
"id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"type": "session"
}
}
HTTPie example
$ http post SERVER:PORT/api/sessions Accept:application/vnd.api+json Content-Type:application/vnd.api+json Api-Key:KKKKKKKK-KKKK-KKKK-KKKK-KKKKKKKKKKKK << JSON
{
"data": {
"attributes": {
"note": "A session note"
},
"type": "session"
}
}
JSON