> ## Documentation Index
> Fetch the complete documentation index at: https://docs.toolrouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Credentials Status

> Check the credential configuration status for a server in your stack

## Overview

Retrieves the status of required and optional credentials for a specific server in your stack. This helps you understand which credentials are already configured and which are missing.

## Endpoint

```
GET https://api.toolrouter.ai/v1/stacks/{stack_id}/servers/{server_id}/credentials
```

## Authentication

This endpoint requires an API key. Include it in the Authorization header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

<ParamField path="stack_id" type="string" required>
  The unique identifier of the stack containing the server
</ParamField>

<ParamField path="server_id" type="string" required>
  The unique identifier of the server to check credentials for
</ParamField>

## Response

<ResponseField name="required_credentials" type="object">
  Status of required credentials for this server

  <Expandable title="Key-Value Pairs">
    Each key is a credential field ID, and each value is either "added" or "missing"
  </Expandable>
</ResponseField>

<ResponseField name="optional_credentials" type="object">
  Status of optional credentials for this server

  <Expandable title="Key-Value Pairs">
    Each key is a credential field ID, and each value is either "added" or "missing"
  </Expandable>
</ResponseField>

<ResponseField name="all_credentials_added" type="boolean">
  Whether all required and optional credentials have been added
</ResponseField>

<ResponseField name="required_credentials_added" type="boolean">
  Whether all required credentials have been added
</ResponseField>

## Example Request

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000/servers/gmail/credentials" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  headers = {
      "Authorization": "Bearer YOUR_API_KEY"
  }

  response = requests.get(
      "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000/servers/gmail/credentials",
      headers=headers
  )

  status = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000/servers/gmail/credentials', {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  });

  const status = await response.json();
  ```
</CodeGroup>

## Example Response

### All Credentials Configured

```json theme={null}
{
  "required_credentials": {
    "gmail_oauth_token": "added",
    "gmail_client_id": "added",
    "gmail_client_secret": "added"
  },
  "optional_credentials": {
    "gmail_signature": "added",
    "gmail_default_sender": "added"
  },
  "all_credentials_added": true,
  "required_credentials_added": true
}
```

### Some Credentials Missing

```json theme={null}
{
  "required_credentials": {
    "gmail_oauth_token": "added",
    "gmail_client_id": "missing",
    "gmail_client_secret": "missing"
  },
  "optional_credentials": {
    "gmail_signature": "missing",
    "gmail_default_sender": "missing"
  },
  "all_credentials_added": false,
  "required_credentials_added": false
}
```

### No Credentials Configured

```json theme={null}
{
  "required_credentials": {
    "gmail_oauth_token": "missing",
    "gmail_client_id": "missing",
    "gmail_client_secret": "missing"
  },
  "optional_credentials": {
    "gmail_signature": "missing",
    "gmail_default_sender": "missing"
  },
  "all_credentials_added": false,
  "required_credentials_added": false
}
```

## Understanding the Response

### Status Values

* **"added"**: The credential has been configured and is available for use
* **"missing"**: The credential has not been configured yet

### Boolean Flags

* **`required_credentials_added`**: `true` if all required credentials are configured. Tools may not work properly if this is `false`.
* **`all_credentials_added`**: `true` if both required and optional credentials are configured. This indicates full functionality is available.

## Use Cases

### Before Tool Usage

Check credential status before using tools to ensure they will work:

```python theme={null}
# Check credentials first
status_response = requests.get(f"https://api.toolrouter.ai/v1/stacks/{stack_id}/servers/{server_id}/credentials", headers=headers)
status = status_response.json()

if not status["required_credentials_added"]:
    print("Required credentials missing. Please configure them before using tools.")
    # Handle missing credentials
else:
    # Proceed with tool usage
    pass
```

### Configuration Validation

Verify credential setup after adding a server to a stack:

```python theme={null}
# Add server to stack
add_response = requests.post(f"https://api.toolrouter.ai/v1/stacks/{stack_id}/servers", headers=headers, json=server_data)

# Check credential status
status_response = requests.get(f"https://api.toolrouter.ai/v1/stacks/{stack_id}/servers/{server_id}/credentials", headers=headers)
status = status_response.json()

# Show which credentials need to be configured
for cred_id, status_value in status["required_credentials"].items():
    if status_value == "missing":
        print(f"Required credential '{cred_id}' needs to be configured")
```

### Monitoring and Alerts

Use this endpoint to monitor credential health across your stacks:

```python theme={null}
# Check all servers in a stack
for server in stack_servers:
    status_response = requests.get(f"https://api.toolrouter.ai/v1/stacks/{stack_id}/servers/{server['server_id']}/credentials", headers=headers)
    status = status_response.json()
    
    if not status["required_credentials_added"]:
        print(f"Alert: Server {server['server_id']} has missing required credentials")
```

## Error Responses

<ResponseField name="401 Unauthorized">
  Invalid or missing API key

  ```json theme={null}
  {
    "detail": "Unauthorized"
  }
  ```
</ResponseField>

<ResponseField name="404 Not Found">
  Stack, server, or server not found in stack

  ```json theme={null}
  {
    "detail": "Stack not found"
  }
  ```

  ```json theme={null}
  {
    "detail": "Server gmail not found in stack stack_123e4567-e89b-12d3-a456-426614174000"
  }
  ```
</ResponseField>

<ResponseField name="429 Too Many Requests">
  Rate limit exceeded

  ```json theme={null}
  {
    "detail": "Too many requests"
  }
  ```
</ResponseField>

<ResponseField name="500 Internal Server Error">
  Server error occurred

  ```json theme={null}
  {
    "detail": "Failed to get credentials status"
  }
  ```
</ResponseField>

## Next Steps

After checking credentials status:

1. **Configure missing credentials**: Use [Update Credentials](/api-reference/endpoint/account/update_credentials) to add missing credentials
2. **Test functionality**: Try invoking tools to ensure credentials work properly
3. **Monitor regularly**: Check credentials status periodically to ensure they remain valid
