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:

Authorization: Bearer YOUR_API_KEY

Path Parameters

stack_id
string
required

The unique identifier of the stack containing the server

server_id
string
required

The unique identifier of the server to check credentials for

Response

required_credentials
object

Status of required credentials for this server

optional_credentials
object

Status of optional credentials for this server

all_credentials_added
boolean

Whether all required and optional credentials have been added

required_credentials_added
boolean

Whether all required credentials have been added

Example Request

curl -X GET "https://api.toolrouter.ai/v1/stacks/stack_123e4567-e89b-12d3-a456-426614174000/servers/gmail/credentials" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

All Credentials Configured

{
  "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

{
  "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

{
  "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:

# 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:

# 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:

# 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

401 Unauthorized

Invalid or missing API key

{
  "detail": "Unauthorized"
}
404 Not Found

Stack, server, or server not found in stack

{
  "detail": "Stack not found"
}
{
  "detail": "Server gmail not found in stack stack_123e4567-e89b-12d3-a456-426614174000"
}
429 Too Many Requests

Rate limit exceeded

{
  "detail": "Too many requests"
}
500 Internal Server Error

Server error occurred

{
  "detail": "Failed to get credentials status"
}

Next Steps

After checking credentials status:

  1. Configure missing credentials: Use 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