> This page is for version v1.3 (default).
> For other versions, use one of these documentation indexes:
> - v1.3 (default): https://docs.twelvelabs.io/v1.3/llms.txt

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

# Generate a picker token

POST https://api.twelvelabs.io/v1.3/connections/{connection_id}/picker-token

This method generates a short-lived, read-only access token that you use with the provider's file picker, such as the Google Drive Picker. The platform never returns the refresh token of the connection.


Reference: https://docs.twelvelabs.io/api-reference/data-connectors/generate-a-picker-token

## Authentication

- `x-api-key` header (required) — Your API key. You can find your API key on the API Keys page.

## Request

### Path parameters

- `connection_id` (string, required) — The unique identifier of the connection.

## Response

### 200

The picker token has been successfully generated.

- `access_token` (string, optional) — A short-lived, read-only access token for use with the provider's file picker.
- `expires_in` (integer, optional) — The number of seconds until the token expires.
- `scope` (string, optional) — A space-delimited list of the scopes granted to the token.
- `app_id` (string, optional) — The Google Cloud project number, used with the Google Picker's `setAppId`. May be absent if the provider does not require this value for its picker.
- `developer_key` (string, optional) — A browser API key, used with the Google Picker's `setDeveloperKey`. May be absent if the provider does not require this value for its picker.

## Errors

### 400 Bad Request Error

The request has failed.

- `code` (string, optional) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details.
- `message` (string, optional) — A human-readable string describing the error, intended to be suitable for display in a user interface.

### 404 Not Found Error

The specified connection does not exist.

- `code` (string, optional) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details.
- `message` (string, optional) — A human-readable string describing the error, intended to be suitable for display in a user interface.
- `docs_url` (string, optional) — The URL of the relevant documentation page.

### 409 Conflict Error

The connection is not in an active state.

- `code` (string, optional) — A string representing the code associated with the error. See the [Error codes](/v1.3/api-reference/error-codes) page for details.
- `message` (string, optional) — A human-readable string describing the error, intended to be suitable for display in a user interface.
- `docs_url` (string, optional) — The URL of the relevant documentation page.

## Examples

**Response**

```json
{
  "access_token": "ya29.a0Ad...",
  "expires_in": 3600,
  "scope": "https://www.googleapis.com/auth/drive.readonly",
  "app_id": "111111111111",
  "developer_key": "AIzaSyBrowserKeyExample"
}
```

**SDK Code**

```python
import requests

url = "https://api.twelvelabs.io/v1.3/connections/665f0a2c9b1e4d0012a3f7c9/picker-token"

headers = {"x-api-key": "<apiKey>"}

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

print(response.json())
```

```javascript
const url = 'https://api.twelvelabs.io/v1.3/connections/665f0a2c9b1e4d0012a3f7c9/picker-token';
const options = {method: 'POST', headers: {'x-api-key': '<apiKey>'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api.twelvelabs.io/v1.3/connections/665f0a2c9b1e4d0012a3f7c9/picker-token"

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

	req.Header.Add("x-api-key", "<apiKey>")

	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://api.twelvelabs.io/v1.3/connections/665f0a2c9b1e4d0012a3f7c9/picker-token")

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

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'

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://api.twelvelabs.io/v1.3/connections/665f0a2c9b1e4d0012a3f7c9/picker-token")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.twelvelabs.io/v1.3/connections/665f0a2c9b1e4d0012a3f7c9/picker-token', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.twelvelabs.io/v1.3/connections/665f0a2c9b1e4d0012a3f7c9/picker-token");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.twelvelabs.io/v1.3/connections/665f0a2c9b1e4d0012a3f7c9/picker-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()
```