> This page is for APIs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# List API tokens

GET https://%7BYour_Space_Name%7D.signalwire.com/api/project/tokens

Lists the project API tokens the caller can manage, newest first. Use it to find the `id` of a token before you [update](/docs/apis/rest/project-tokens/update-token), [regenerate](/docs/apis/rest/project-tokens/regenerate-token), or [delete](/docs/apis/rest/project-tokens/delete-token) it, or to check when each token last authenticated a request.

Token values are never returned. A token's value appears only in the response that issued it: [Create API token](/docs/apis/rest/project-tokens/create-token) or [Regenerate API token](/docs/apis/rest/project-tokens/regenerate-token).

With a project API token, the list covers the tokens of the authenticated project and its subprojects. With a [Personal access token](/docs/apis/authorization#personal-access-tokens), it covers the tokens of every project the token holder is enabled for, plus their subprojects. Pass `project_id` to narrow the list to one project.

#### Permissions

With a project API token, the token must have the following scope(s) enabled to make a successful request: _Management_.

With a [Personal access token](/docs/apis/authorization#personal-access-tokens) there are no scopes. The token holder must be an owner or admin of the space, and the request reaches only the projects the holder is enabled for, plus their subprojects.

[Learn more about API scopes](/docs/platform/your-signalwire-api-space).

Reference: https://signalwire.com/docs/apis/rest/project-tokens/list-tokens

## Authentication

- `Authorization` header (basic auth, required) — SignalWire Basic Authentication using Project ID and API Token. The client sends HTTP requests with the Authorization header containing the word Basic followed by a space and a base64-encoded string of project_id:token. The project ID will be used as the username and the API token as the password. Example: ``` Authorization: Basic base64(project_id:token) ```
- `Authorization` header (basic auth, required) — Personal access token authentication for space-wide administration. Send HTTP Basic auth with an empty username and the Personal access token as the password. A Personal access token carries your own authority rather than a project's: it is created from your user menu in the Dashboard, is prefixed `pat_`, and has no scopes. The holder must be an owner or admin of the space named by the subdomain, and the token acts only on that space. Example: ``` Authorization: Basic base64(:pat_...) ```

## Request

### Query parameters

- `project_id` (string, optional) — Only return tokens that belong to this project. A project the caller cannot reach, or a value that is not a valid project ID, returns an empty list rather than an error.
- `page_size` (integer, optional, default: 50) — The number of results per page.
- `page_token` (string, optional) — Cursor token for paging, taken from the `next` or `prev` link of a previous response.
- `page_number` (integer, optional, default: 0) — The page index. A value above 0 requires `page_token`.

## Response

### 200

The request has succeeded.

- `links` (Project.TokenPaginationLinks, required) — Pagination links for the list of tokens.
- `data` (list of Project.TokenResponse, required) — The tokens on this page. Token values are never included.

## Errors

### 401 Unauthorized Error

Access is unauthorized.

- `error` (enum, required)
  - Allowed values: `Unauthorized`

### 422 Unprocessable Entity Error

A pagination parameter is invalid. A `page_token` that is not a cursor from a previous response returns `page_token_is_invalid`, and a `page_number` above 0 without a `page_token` returns `page_token_required_for_next_page`. A `page_size` outside 1 to 1000, a `page_number` that is negative or not an integer, or a `project_id` that is not a single value returns `invalid_parameter`.

- `errors` (list of Types.StatusCodes.RestApiErrorItem, required) — List of validation errors.

### 500 Internal Server Error

An internal server error occurred.

- `error` (enum, required)
  - Allowed values: `Internal Server Error`

## Types

### Project.TokenPaginationLinks

Pagination links for a list of API tokens.

- `self` (string, required) — The link to the current page.
- `first` (string, required) — The link to the first page.
- `next` (string, optional) — The link to the next page. Only present when more results exist.
- `prev` (string, optional) — The link to the previous page. Only present when a previous page exists.

### Project.TokenResponse

- `id` (string, required) — The ID of the API Token.
- `name` (string, required, nullable) — The name of the API Token. `null` when the token has no name.
- `permissions` (list of enum, required) — The permissions enabled for this token.
  - Allowed values: `calling`, `chat`, `datasphere`, `fax`, `management`, `messaging`, `numbers`, `pubsub`, `storage`, `tasking`, `video`
- `last_used_at` (datetime, required, nullable) — The date and time the token last authenticated a request. `null` if it never has.
- `revoked_at` (datetime, required, nullable) — The date and time SignalWire revoked the token's value, for example after detecting that the value was exposed. `null` if it has not been revoked. A revoked token keeps its `id` and still appears in [List API tokens](/docs/apis/rest/project-tokens/list-tokens), but its previous value no longer authenticates and no replacement value has been issued to you. To get a working value, [regenerate the token](/docs/apis/rest/project-tokens/regenerate-token), which also clears `revoked_at`.

### Types.StatusCodes.RestApiErrorItem

Details about a specific error.

- `type` (string, required) — The category of error.
- `code` (string, required) — A specific error code.
- `message` (string, required) — A description of what caused the error.
- `url` (string, required) — A link to documentation about this error.
- `attribute` (string, optional, nullable) — The request parameter that caused the error, if applicable.

## Examples

**Response**

```json
{
  "links": {
    "self": "https://example-space.signalwire.com/api/project/tokens?page_number=0&page_size=50",
    "first": "https://example-space.signalwire.com/api/project/tokens?page_size=50",
    "next": "https://example-space.signalwire.com/api/project/tokens?page_number=1&page_size=50&page_token=PAea14556a-984f-11ee-b9d1-0242ac120002",
    "prev": "https://example-space.signalwire.com/api/project/tokens?page_number=0&page_size=50&page_token=PBea14556a-984f-11ee-b9d1-0242ac120002"
  },
  "data": [
    {
      "id": "ea14556a-984f-11ee-b9d1-0242ac120002",
      "name": "John Doe's Token",
      "permissions": [
        "calling",
        "fax",
        "messaging"
      ],
      "last_used_at": "2024-05-06T12:20:00Z",
      "revoked_at": null
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://{your_space_name}.signalwire.com/api/project/tokens"

response = requests.get(url, auth=("<project_id>", "<api_token>"))

print(response.json())
```

```javascript
const url = 'https://{your_space_name}.signalwire.com/api/project/tokens';
const credentials = btoa("<project_id>:<api_token>");

const options = {method: 'GET', headers: {Authorization: `Basic ${credentials}`}};

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://{your_space_name}.signalwire.com/api/project/tokens"

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

	req.SetBasicAuth("<project_id>", "<api_token>")

	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://{your_space_name}.signalwire.com/api/project/tokens")

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

request = Net::HTTP::Get.new(url)
request.basic_auth("<project_id>", "<api_token>")

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.get("https://{your_space_name}.signalwire.com/api/project/tokens")
  .basicAuth("<project_id>", "<api_token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://{your_space_name}.signalwire.com/api/project/tokens', [
  'headers' => [
  ],
    'auth' => ['<project_id>', '<api_token>'],
]);

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

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://{your_space_name}.signalwire.com/api/project/tokens");
client.Authenticator = new HttpBasicAuthenticator("<project_id>", "<api_token>");
var request = new RestRequest(Method.GET);

IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<project_id>:<api_token>".utf8).base64EncodedString()

let headers = ["Authorization": "Basic \(credentials)"]

let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/project/tokens")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```