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

# /token

POST https://token
Content-Type: application/json

POST API login parameters to request an API token for x-auth header authentication.

Required:
api\_key string
api\_secret string

Expires is UNIX timestamp in seconds from epoch UTC.  Request a new token before expiry to avoid API request errors.

Return:

\{
"token": \{
"value": "98ikasfd08oi43qs9d0uik48wu0oiweiuh4f9a87uiasdf78q9yd8oasudfy7893898u09afijoja4w8oaf8osoadf8o2oohhasdf80",
"expires": "1558413892"
}
}

Reference: https://docs.odr.io/odr-search-api-v-4/token

## Request

### Body (application/json)

This endpoint expects an object.

- `username` (string, required)
- `password` (string, required)

## Response

### 200

OK

- `token` (string, required)

## Examples

**Request**

```json
{
  "username": "{{apiuser}}",
  "password": "{{apipass}}"
}
```

**Response**

```json
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpYXQiOjE1NTc1MTI5NDksImV4cCI6MTU1Nzg3Mjk0OSwicm9sZXMiOlsiUk9MRV9BRE1JTiIsIlJPTEVfU1VQRVJfQURNSU4iLCJST0xFX1VTRVIiXSwidXNlcm5hbWUiOiJuYXRlQG9wZW5kYXRhcmVwb3NpdG9yeS5vcmcifQ.VzhNaHQze2s_JCQUaoqIhe4ohGIF8hewZFC_mPy4sia3F8diE5GpLNlc3OWS7V10GTdDArjcIbrEvocsZOm5MvSyIOKNR9IXvQPGOpFqy-4WX_8cM5IemKjUbg1KCTKcTHUwkSg6yjHTQaQVRMLSP8NqZtthikv3Nz7shDCVWEbTET9yWG4RS6BAazPPZONndwiXztM-VH_xbjl-fOznVP5XPid4sw_oOfijpl7h5YUP6V-syWgBk-hKxE0BUUJfqBvG8ZqJZOmoGCopN0B-9E6pdE3e7HmixkCdZRMnMst5C3961qrqrP8VjfurqlzDRW9n16Rk3aUxUstiSyiR62Uyn3rzw87dzCANckQ75B4WVsuFr3CqHER1as7dFwhkFU-ZOHn1dTO6fX4y7RAUUlq3UUhWL8sJu-dxl9mRzjg117LKuquUbZkU6xrTtSPdDvO4Rzi6GQ4dAawiEG-ehSGYVJgFl9GqyQH5rAYpuO_mR88m5vO9m-SoUhA4pwZnEsp7v_uuUejbr44FmKpjBhcnH85S7d4cYbl9bPa9o_ecyQ2aRhFMLc-hqMMMD2SOAXcbRgtl8Jx75NY9kQ39pcrRuhg6CV48JJrCQW0yv0al0R85tNKnyB7yMDabKGjVq9tXR4SrLh3n_qWziWi488BQSFyc-z5RQFV10B7VSNM"
}
```

**SDK Code**

```python /token_example
import requests

url = "https://https/token"

payload = {
    "username": "{{apiuser}}",
    "password": "{{apipass}}"
}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript /token_example
const url = 'https://https/token';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"username":"{{apiuser}}","password":"{{apipass}}"}'
};

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

```go /token_example
package main

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

func main() {

	url := "https://https/token"

	payload := strings.NewReader("{\n  \"username\": \"{{apiuser}}\",\n  \"password\": \"{{apipass}}\"\n}")

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

	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 /token_example
require 'uri'
require 'net/http'

url = URI("https://https/token")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"username\": \"{{apiuser}}\",\n  \"password\": \"{{apipass}}\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://https/token")
  .header("Content-Type", "application/json")
  .body("{\n  \"username\": \"{{apiuser}}\",\n  \"password\": \"{{apipass}}\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://https/token', [
  'body' => '{
  "username": "{{apiuser}}",
  "password": "{{apipass}}"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp /token_example
using RestSharp;

var client = new RestClient("https://https/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"username\": \"{{apiuser}}\",\n  \"password\": \"{{apipass}}\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift /token_example
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "username": "{{apiuser}}",
  "password": "{{apipass}}"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://https/token")! 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()
```