# Get an API key

Returns one API key with its policy, its masked secret preview, its validity window, and when it was last used. The secret itself is never readable after creation.

GET `/v1/api-keys/{apiKeyId}`

## Authorization

`Authorization` Bearer token · header required

```plaintext
Authorization: Bearer <token>
```

with an API key (`sfa_` prefix), an OAuth access token, a session token, or a Space machine credential (`sfm_` prefix).

or

`Authorization` OAuth2 access token · header required

OAuth 2.0 with Spacefast scopes. People use the authorization code flow; machines use client credentials.

**Scopes:** `teams:read`

## Path parameters

**`apiKeyId`** string required  
   min length 1

## Responses

### 200 Response for status 200

```json
{
  "$schema": "string<uri>",
  "data": {
    "collection": "string",
    "createdAt": "string<date-time>",
    "createdByUserId": "string",
    "enabled": true,
    "expiresAt": "string<date-time> | any",
    "id": "string",
    "ipAllowlist": ["string"],
    "lastRequestAt": "string<date-time> | any",
    "metadata": {
      "name": "string | any"
    },
    "notBefore": "string<date-time> | any",
    "ownerPrincipal": {
      "type": "string",
      "id": "string"
    },
    "policy": {
      "statements": [{
        "actions": ["string"],
        "conditions": {},
        "effect": "string",
        "resources": ["string"]
      }],
      "version": "string"
    },
    "preset": "string | any",
    "revokedAt": "string<date-time> | any",
    "secretPreview": "string",
    "subject": {
      "type": "string",
      "id": "string"
    },
    "teamScope": {},
    "updatedAt": "string<date-time>"
  }
}
```

```
{
  "$schema": "string<uri>",
  "type": "string",
  "title": "string",
  "status": integer,
  "detail": "string",
  "code": "string",
  "pointer": "string",
  "details": {},
  "suggestions": ["string"],
  "next": ["string"],
  "requestId": "string"
}
```

## Try it

### Server
**Base URL** https://api.spacefast.com

```bash
curl -X GET "https://api.spacefast.com/v1/api-keys/string" \
  -H "Authorization: Bearer YOUR_TOKEN"
```

```javascript
const response = await fetch("https://api.spacefast.com/v1/api-keys/string", {
  method: "GET",
  headers: {
    "Authorization": "Bearer YOUR_TOKEN"
  }
});
```

```python
import requests

response = requests.get(
    "https://api.spacefast.com/v1/api-keys/string",
    headers={
        "Authorization": "Bearer YOUR_TOKEN"
    },
)
```
