> This page is for version v1.0.
> For other versions, use one of these documentation indexes:
> - v2.0 (default): https://docs.cable.tech/v-2-0/llms.txt
> - v1.0: https://docs.cable.tech/v-1-0/llms.txt

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

# Request a new access token

POST https://transaction-api.cable.tech/auth/token
Content-Type: application/json

Request a new access token to authenticate requests to the API. The token will expire after the specified time. To request an access token you must use the refresh / auth token provided to you by Cable. You cannot request a new token with an existing access token.

Reference: https://docs.cable.tech/v-1-0/api-reference/transaction-data-api/authentication/request-token

## Authentication

- `Authorization` header (required) — API Key authentication via header

## Request

### Body (application/json)

This endpoint expects a NewAccessTokenRequest.

- `expiry_seconds` (long, required) — The requested expiration time in seconds for the token. Must be between 300 (5 minutes) and 86400 (24 hours).
- `scopes` (AccessTokenScope, required)

## Response

### 200

Token created successfully

- `token` (string, required)
- `expiry` (long, required) — The expiration time in Unix time format.
- `organization_id` (string, required) — The organization ID for which the token was requested.
- `organization_name` (string, required) — The name of the organization for which the token was requested.
- `scopes` (AccessTokenScope, optional)

## Errors

### 401 Unauthorized Error

Unauthorized request

- `code` (integer, required)
- `message` (string, required)
- `errors` (list of GeneralErrorErrorsItems, optional) — Detailed information about errors in specific fields.

### 429 Too Many Requests Error

Rate limit exceeded

- `code` (integer, required)
- `message` (string, required)
- `errors` (list of GeneralErrorErrorsItems, optional) — Detailed information about errors in specific fields.

### 500 Internal Server Error

Server error

- `code` (integer, required)
- `message` (string, required)
- `errors` (list of GeneralErrorErrorsItems, optional) — Detailed information about errors in specific fields.

## Types

### AccessTokenScope

- `organization_id` (string, required) — The organization ID for which the token is requested. This is required.
- `scopes` (list of string, required) — The list of scopes that the token should have. For transaction data, the scope should be 'transactions:write'.

### GeneralErrorErrorsItems

- `field` (string, optional)
- `message` (string, optional)

## Examples

**Request**

```json
{
  "expiry_seconds": 3600,
  "scopes": {
    "organization_id": "org_9f8b7c6d5e4a3b2c1d0e",
    "scopes": [
      "transactions:write"
    ]
  }
}
```

**Response**

```json
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
  "expiry": 1711929600,
  "organization_id": "org_9f8b7c6d5e4a3b2c1d0e",
  "organization_name": "Cable Financial Services",
  "scopes": {
    "organization_id": "org_9f8b7c6d5e4a3b2c1d0e",
    "scopes": [
      "transactions:write"
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "https://transaction-api.cable.tech/auth/token"

payload = {
    "expiry_seconds": 3600,
    "scopes": {
        "organization_id": "org_9f8b7c6d5e4a3b2c1d0e",
        "scopes": ["transactions:write"]
    }
}
headers = {
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://transaction-api.cable.tech/auth/token';
const options = {
  method: 'POST',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"expiry_seconds":3600,"scopes":{"organization_id":"org_9f8b7c6d5e4a3b2c1d0e","scopes":["transactions:write"]}}'
};

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://transaction-api.cable.tech/auth/token"

	payload := strings.NewReader("{\n  \"expiry_seconds\": 3600,\n  \"scopes\": {\n    \"organization_id\": \"org_9f8b7c6d5e4a3b2c1d0e\",\n    \"scopes\": [\n      \"transactions:write\"\n    ]\n  }\n}")

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

	req.Header.Add("Authorization", "<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://transaction-api.cable.tech/auth/token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"expiry_seconds\": 3600,\n  \"scopes\": {\n    \"organization_id\": \"org_9f8b7c6d5e4a3b2c1d0e\",\n    \"scopes\": [\n      \"transactions:write\"\n    ]\n  }\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://transaction-api.cable.tech/auth/token")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"expiry_seconds\": 3600,\n  \"scopes\": {\n    \"organization_id\": \"org_9f8b7c6d5e4a3b2c1d0e\",\n    \"scopes\": [\n      \"transactions:write\"\n    ]\n  }\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://transaction-api.cable.tech/auth/token', [
  'body' => '{
  "expiry_seconds": 3600,
  "scopes": {
    "organization_id": "org_9f8b7c6d5e4a3b2c1d0e",
    "scopes": [
      "transactions:write"
    ]
  }
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://transaction-api.cable.tech/auth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"expiry_seconds\": 3600,\n  \"scopes\": {\n    \"organization_id\": \"org_9f8b7c6d5e4a3b2c1d0e\",\n    \"scopes\": [\n      \"transactions:write\"\n    ]\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "expiry_seconds": 3600,
  "scopes": [
    "organization_id": "org_9f8b7c6d5e4a3b2c1d0e",
    "scopes": ["transactions:write"]
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://transaction-api.cable.tech/auth/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()
```