# apiKeys

```graphql
query ApiKeys {
  apiKeys {
    data {
      id
      projectId
      userId
      accountId
      name
      keyPrefix
      lastUsedAt
      expiresAt
      createdAt
      updatedAt
      status
      revokedAt
      scopes
      scope
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    totalCount
  }
}
```

List the caller's API keys, or the keys bound to one project, newest first; every surface returns active keys unless status selects expired, revoked or all.

## Arguments

| Name                     | Type            | Required | Description                                                                                                                                                                                                           |
| ------------------------ | --------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `input`                  | ApiKeysInput    |          |                                                                                                                                                                                                                       |
| `input.projectReference` | String          |          | Project ID or slug. Listing the keys bound to a project requires project.api\_keys.read. Omit to list the caller's own keys; a project-scoped API-key caller retains its enforced project when this field is omitted. |
| `input.limit`            | Int             |          |                                                                                                                                                                                                                       |
| `input.cursor`           | String          |          |                                                                                                                                                                                                                       |
| `input.status`           | String          |          | Which keys to list: active (the default), expired, revoked or all.                                                                                                                                                    |
| `input.sortBy`           | ApiKeySortBy    |          | Field to sort by. Ties break by key ID ascending. Default `created_at`. One of `created_at`, `name`, `last_used_at`.                                                                                                  |
| `input.sortOrder`        | ApiKeySortOrder |          | Sort direction. Default `desc`. One of `asc`, `desc`.                                                                                                                                                                 |

## Responses

| Status | Description                          |
| ------ | ------------------------------------ |
| 200    | The ApiKeysPayload! in data.apiKeys. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "query ApiKeys {\n  apiKeys {\n    data {\n      id\n      projectId\n      userId\n      accountId\n      name\n      keyPrefix\n      lastUsedAt\n      expiresAt\n      createdAt\n      updatedAt\n      status\n      revokedAt\n      scopes\n      scope\n    }\n    pageInfo {\n      hasNextPage\n      hasPreviousPage\n      startCursor\n      endCursor\n    }\n    totalCount\n  }\n}"
}'
```

## Example response

```json
{
  "data": {
    "apiKeys": {
      "data": [
        {
          "id": "string",
          "projectId": "string",
          "userId": "string",
          "accountId": "string",
          "name": "string",
          "keyPrefix": "string",
          "lastUsedAt": "string",
          "expiresAt": "string",
          "createdAt": "string",
          "updatedAt": "string",
          "status": "string",
          "revokedAt": "string",
          "scopes": [
            "string"
          ],
          "scope": "string"
        }
      ],
      "pageInfo": {
        "hasNextPage": false,
        "hasPreviousPage": false,
        "startCursor": "string",
        "endCursor": "string"
      },
      "totalCount": 0
    }
  }
}
```
