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

# Store Credential

> Store an API key or bearer token for a service

## Overview

Stores a credential (API key or bearer token) for a service so that Danube can authenticate tool executions on your behalf. This is the agent-friendly credential storage endpoint — designed for programmatic use from SDKs and MCP clients.

For OAuth credentials, use the dashboard OAuth flow instead.

**Auth:** Requires API key (`danube-api-key` header).

## Body Parameters

<ParamField body="service_id" type="string" required>
  UUID of the service to store credentials for
</ParamField>

<ParamField body="credential_type" type="string" required>
  Type of credential: `bearer` or `api_key`
</ParamField>

<ParamField body="credential_value" type="string" required>
  The actual credential value (API key or bearer token)
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Whether the credential was stored successfully
</ResponseField>

<ResponseField name="service_id" type="string">
  The service the credential is for
</ResponseField>

<ResponseField name="service_name" type="string">
  Human-readable service name
</ResponseField>

<ResponseField name="credential_type" type="string">
  The type that was stored
</ResponseField>

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.danubeai.com/v1/credentials/store" \
    -H "danube-api-key: YOUR_DANUBE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "service_id": "svc_openai_001",
      "credential_type": "bearer",
      "credential_value": "sk-proj-abc123..."
    }'
  ```

  ```python Python SDK theme={null}
  # Via MCP tool
  result = await mcp.call_tool("store_credential", {
      "service_id": "svc_openai_001",
      "credential_type": "bearer",
      "credential_value": "sk-proj-abc123..."
  })
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "success": true,
    "service_id": "svc_openai_001",
    "service_name": "OpenAI",
    "credential_type": "bearer"
  }
  ```
</ResponseExample>

## MCP Tool

This endpoint is also available as the `store_credential` MCP tool:

```python theme={null}
result = await mcp.call_tool("store_credential", {
    "service_id": "svc_openai_001",
    "credential_type": "bearer",
    "credential_value": "sk-proj-abc123..."
})
```

## Notes

* Credentials are encrypted at rest using AES-256
* Only `bearer` and `api_key` types are supported via this endpoint
* For OAuth, use the dashboard credential flow at `/dashboard/tools/:serviceId`
* Storing a new credential for the same service replaces the existing one
