> This page is for version v2.
> For other versions, use one of these documentation indexes:
> - v1 (default): https://developers.outpave.com/v1/llms.txt
> - v2: https://developers.outpave.com/v2/llms.txt

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

# Create access token

POST https://api.outpave.com/api/v1/access-token

Exchanges your long-lived API key for a short-lived JWT (30 minutes
by default). Send the API key as `Authorization: Bearer <api-key>`;
use the returned JWT as `Authorization: Bearer <jwt>` on every other
endpoint.

Treat the API key like a password — keep it on a trusted backend and
never ship it in a browser or mobile app.

Reference: https://developers.outpave.com/api-reference/customer-portal-api/authentication/post-api-v-1-access-token

## Authentication

- `Authorization` header (bearer token, required) — Your long-lived API key, sent as `Authorization: Bearer <api-key>` (format `op_api_{id}_{secret}`). Only valid on `POST /api/v1/access-token`. Every other endpoint requires a JWT.

## Response

### 200

Access token created.

- `token` (string, required) — The access token. Send as `Authorization: Bearer <token>` on subsequent requests.
- `tokenType` (enum, required) — Always `Bearer`.
  - Allowed values: `Bearer`
- `expiresIn` (integer, required) — Number of seconds until the token expires.
- `expiresAt` (long, required) — Unix timestamp (milliseconds) when the token expires.

## Errors

### 401 Unauthorized Error

The credential is missing, invalid, expired, or not permitted on this endpoint.

- `error` (string, required) — A short, human-readable error message.
- `details` (list of string, optional) — Additional error details (returned on validation failures).

### 500 Internal Server Error

An unexpected server error occurred. Retry the request; if the problem persists, contact support.

- `error` (string, required) — A short, human-readable error message.
- `details` (list of string, optional) — Additional error details (returned on validation failures).

## Examples

**Response**

```json
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "tokenType": "Bearer",
  "expiresIn": 1800,
  "expiresAt": 1717852800000
}
```

**SDK Code**

```python success
import requests

url = "https://api.outpave.com/api/v1/access-token"

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript success
const url = 'https://api.outpave.com/api/v1/access-token';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

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

```go success
package main

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

func main() {

	url := "https://api.outpave.com/api/v1/access-token"

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

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby success
require 'uri'
require 'net/http'

url = URI("https://api.outpave.com/api/v1/access-token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

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

```java success
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.outpave.com/api/v1/access-token")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.outpave.com/api/v1/access-token', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp success
using RestSharp;

var client = new RestClient("https://api.outpave.com/api/v1/access-token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift success
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.outpave.com/api/v1/access-token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```