> This page is for Postman API Docs.

> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Get collection access keys

GET https://api.postman.com/collection-access-keys

Gets the authenticated user's personal and team [collection access keys](https://learning.postman.com/docs/developer/postman-api/authentication/#generate-a-collection-access-key).

**Note:**

- The `expiresAfter` property in the response represents the date and time at which the access key expires. Collection access keys are valid for 60 days. If unused, the access key expires after 60 days. If someone uses the access key, then its expiration date increases by another 60 days.
- If the collection key is unused, the `lastUsedAt` property in the response returns an empty string.


Reference: https://learning.postman.com/api-docs/api-reference/collection-access-keys/get-collection-access-keys

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Servers

- `https://api.postman.com` (https://api.postman.com, default)
- `https://api.eu.postman.com` (https://api.eu.postman.com)

## Request

### Query parameters

- `collectionId` (string, optional) — Filter the results by a collection's unique ID.
- `cursor` (string, optional) — The pointer to the first record of the set of paginated results. To view the next response, use the `nextCursor` value for this parameter.

## Response

### 200

Successful Response

- `data` (list of GetCollectionAccessKeysDataItems, optional) — A list of collection access keys.
- `meta` (GetCollectionAccessKeysMeta, optional) — The response's non-standard metadata information.

## Errors

### 400 Bad Request Error

Bad Request

- `GetCollectionAccessKeysRequestBadRequestError`
  - Error (Type, Title, Detail): commonErrorTypeTitleDetail
  - Error (Type, Title, Detail, Status): commonErrorTypeTitleDetailStatus
  - Error (Name, Message, Details): commonErrorNameMessageDetails

### 401 Unauthorized Error

Unauthorized

- `GetCollectionAccessKeysRequestUnauthorizedError`
  - Error (Type, Title, Detail, Status): commonErrorTypeTitleDetailStatus
  - Error (Name, Message): commonErrorNameMessage

### 403 Forbidden Error

Forbidden

- `GetCollectionAccessKeysRequestForbiddenError`
  - Error (Type, Title, Detail, Status): commonErrorTypeTitleDetailStatus
  - Error (Name, Message): commonErrorNameMessage

### 500 Internal Server Error

Internal Server Error

- `GetCollectionAccessKeysRequestInternalServerError`
  - Error (Type, Title, Detail): commonErrorTypeTitleDetail
  - Error (Type, Title, Detail, Status): commonErrorTypeTitleDetailStatus
  - Error (Name, Message): commonErrorNameMessage

## Types

### GetCollectionAccessKeysDataItems

Information about the collection access key.

- `id` (string, optional) — The collection access key's ID.
- `token` (string, optional) — The masked collection access key.
- `status` (enum, optional) — The token's active status.
  - Allowed values: `ACTIVE`, `INACTIVE`
- `teamId` (integer, optional) — The team ID of the collection access key's owner.
- `userId` (integer, optional) — The user ID of the collection access key's owner.
- `collectionId` (string, optional) — The collection access key's associated collection ID.
- `expiresAfter` (datetime, optional) — The date and time at which the collection access key expires. Collection access keys are valid for 60 days. If unused, the access key expires after 60 days. If someone uses the access key, then its expiration date increases by another 60 days.
- `lastUsedAt` (string, optional) — The date and time at which the collection access key was used. If the collection key is unused, this returns an empty string value.
- `createdAt` (datetime, optional) — The date and time at which the collection access key was created.
- `updatedAt` (datetime, optional) — The date and time at which the collection access key was updated.
- `deletedAt` (datetime, optional, nullable) — The date and time at which the collection access key was revoked.

### GetCollectionAccessKeysMeta

The response's non-standard metadata information.

- `nextCursor` (string, optional) — The pagination cursor that points to the next record in the results set.
- `prevCursor` (string, optional) — The pagination cursor to previous set of response data.

### commonErrorTypeTitleDetail

- `type` (string, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (CommonErrorTypeTitleDetailDetail, optional) — Information about the error.

### commonErrorTypeTitleDetailStatus

- `type` (CommonErrorTypeTitleDetailStatusType, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — Information about the error.
- `status` (integer, optional) — The error's HTTP status code.

### commonErrorNameMessageDetails

- `error` (CommonErrorNameMessageDetailsError, optional) — Information about the error.

### commonErrorNameMessage

- `error` (CommonErrorNameMessageError, optional) — Information about the error.

### CommonErrorTypeTitleDetailDetail

Information about the error.

- string
- map from string to any

### CommonErrorTypeTitleDetailStatusType

The type of error.

- string
- string

### CommonErrorNameMessageDetailsError

Information about the error.

- `name` (string, optional) — The error name.
- `message` (string, optional) — The error message.
- `details` (CommonErrorNameMessageDetailsErrorDetails, optional) — Information about the error.

### CommonErrorNameMessageError

Information about the error.

- `name` (string, optional) — The error name.
- `message` (string, optional) — The error message.

### CommonErrorNameMessageDetailsErrorDetails

Information about the error.

- map from string to any
- list of string

## Examples

**Response**

```json
{
  "data": [
    {
      "id": "Njg5OjU3MDQ1NjYtYmQxZDU3NzktMWVkNS00ZDhjLWI0ZmQtZWRhOGY2Mzg1NTY0",
      "token": "PMAT-**********************43BR",
      "status": "ACTIVE",
      "teamId": 123,
      "userId": 12345678,
      "collectionId": "12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2",
      "expiresAfter": "2024-06-11T13:21:11.000Z",
      "lastUsedAt": "",
      "createdAt": "2024-04-12T13:21:11.000Z",
      "updatedAt": "2024-04-09T11:00:53.000Z"
    },
    {
      "id": "K7yJPzQ18BC7Snm09PXL12RMmnq57hQorFJW8JnCKhQ11JmNQiTlgXnQ1p93jGYN",
      "token": "PMAT-**********************51FZ",
      "status": "ACTIVE",
      "teamId": 123,
      "userId": 56781234,
      "collectionId": "56781234-68e5e7ac-c134-45f4-9770-40e72f3fc474",
      "expiresAfter": "2024-06-11T13:21:11.000Z",
      "lastUsedAt": "2024-04-29T08:24:23.000Z",
      "createdAt": "2024-04-22T10:11:00.000Z",
      "updatedAt": "2024-04-22T10:11:00.000Z"
    }
  ],
  "meta": {
    "nextCursor": "b2Zmc2V0PTEwJmxpbWl0PTEw",
    "prevCursor": ""
  }
}
```

**SDK Code**

```python Successful Response
import requests

url = "https://api.postman.com/collection-access-keys"

querystring = {"collectionId":"12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2","cursor":"RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk="}

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

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Successful Response
const url = 'https://api.postman.com/collection-access-keys?collectionId=12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2&cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D';
const options = {method: 'GET', 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 Successful Response
package main

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

func main() {

	url := "https://api.postman.com/collection-access-keys?collectionId=12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2&cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D"

	req, _ := http.NewRequest("GET", 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 Successful Response
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/collection-access-keys?collectionId=12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2&cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D")

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

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

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

```java Successful Response
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.postman.com/collection-access-keys?collectionId=12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2&cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.postman.com/collection-access-keys?collectionId=12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2&cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Successful Response
using RestSharp;

var client = new RestClient("https://api.postman.com/collection-access-keys?collectionId=12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2&cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D");
var request = new RestRequest(Method.GET);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Successful Response
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/collection-access-keys?collectionId=12345678-12ece9e1-2abf-4edc-8e34-de66e74114d2&cursor=RnJpIEZlYiAyNCAyMDIzIDEzOjI0OjA5IEdNVCswMDAwIChDb29yZGluYXRlZCBVbml2ZXJzYWwgVGltZSk%3D")! 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()
```