> For the complete documentation index, see [llms.txt](https://docs.360dialog.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.360dialog.com/docs/mba/api-ref/knowledge-connectors/upsert-api-key-credentials-for-a-connector.md).

# Upsert API key credentials for a connector

Set or rotate the API key credentials for this connector. If credentials already exist, they are replaced and the connection is re-established. The credential payload is required; this endpoint will not delete credentials. At least one of headers, query\_params, or body\_params must contain a populated entry; the request fails with HTTP 400 if api\_key\_config is null or missing. To remove an API key layer, delete the connector or change its auth type via the update endpoint instead.

```json
{"openapi":"3.1.0","info":{"title":"Business Agent API","version":"1.51.5"},"tags":[{"name":"Knowledge - Connectors","description":"Endpoints for managing the agent's external API connectors"}],"servers":[{"description":"Production server","url":"https://waba-v2.360dialog.io"}],"security":[{"D360-API-KEY":[]}],"components":{"securitySchemes":{"D360-API-KEY":{"description":"API Key for Messaging API authentication. Send your API key in the D360-API-KEY header.","in":"header","name":"D360-API-KEY","type":"apiKey"}},"schemas":{"knowledge_connectors.BizAIOmniChannelConnectorUpsertApiKeyRequest":{"description":"Set or rotate the API key credentials for a connector","properties":{"api_key_config":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorApiKeyAuthConfig"}},"required":["api_key_config"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorApiKeyAuthConfig":{"description":"API key configuration. Provide only when auth_type is API_KEY.","properties":{"body_params":{"description":"API key fields to add as JSON body parameters","items":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorApiKeyParam"},"type":"array","uniqueItems":false},"headers":{"description":"API key fields to add as HTTP headers","items":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorApiKeyParam"},"type":"array","uniqueItems":false},"query_params":{"description":"API key fields to add as query parameters","items":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorApiKeyParam"},"type":"array","uniqueItems":false}},"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorApiKeyParam":{"description":"A single API key field","properties":{"field_name":{"description":"Header, query parameter, or body field name","type":"string"},"prefix":{"description":"Optional value prefix, such as Bearer followed by a space","type":"string"},"value":{"description":"Secret value for this API key field","type":"string"}},"required":["field_name","value"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorResponse":{"description":"A single connector","properties":{"auth_config":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorAuthConfig"},"auth_type":{"description":"Authentication type for this connector","enum":["OAUTH2","OAUTH2_CLIENT_CREDENTIALS","API_KEY","BASIC","CUSTOM","NONE"],"type":"string"},"base_url":{"description":"Base URL of the external API","type":"string"},"connection_status":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorConnectionStatus"},"connector_protocol":{"description":"Protocol used by this connector. Defaults to HTTP when omitted.","enum":["HTTP","MCP"],"type":"string"},"description":{"description":"Description of the connector","type":"string"},"id":{"description":"The unique identifier for this connector","type":"string"},"mcp_tool_sync":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorMcpToolSync"},"mtls_config":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorMtlsConfig"},"name":{"description":"Display name of the connector","type":"string"},"user_auth_injection_config":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorUserAuthInjectionConfig"}},"required":["auth_type","base_url","connection_status","description","id","name"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorAuthConfig":{"description":"Authentication configuration for this connector","properties":{"api_key":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorApiKeyAuthConfig"},"oauth2_client_credentials":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorOAuth2ClientCredentialsAuthConfig"}},"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorOAuth2ClientCredentialsAuthConfig":{"description":"OAuth 2.0 client credentials configuration. Provide only when auth_type is OAUTH2_CLIENT_CREDENTIALS.","properties":{"client_id":{"description":"OAuth client ID","type":"string"},"client_secret":{"description":"OAuth client secret","type":"string"},"scopes_to_request":{"description":"OAuth scopes to request","items":{"type":"string"},"type":"array","uniqueItems":false},"token_request_content_type":{"description":"Content type for token requests. Supports application/x-www-form-urlencoded and application/json. Defaults to application/x-www-form-urlencoded.","type":"string"},"token_url":{"description":"Token URL used to request OAuth access tokens","type":"string"}},"required":["client_id","client_secret","scopes_to_request","token_url"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorConnectionStatus":{"description":"Connection status information","properties":{"error_message":{"description":"Error message if connection failed","type":"string"},"status":{"description":"Current connection status","enum":["PENDING_OAUTH","ACTIVE","EXPIRED","ERROR"],"type":"string"}},"required":["status"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorMcpToolSync":{"description":"MCP tool discovery cache status. Null for HTTP connectors.","properties":{"fingerprint":{"description":"Fingerprint of the cached remote tool set","type":"string"},"last_attempted_at":{"description":"Unix timestamp of the latest refresh attempt","type":"integer"},"last_successful_at":{"description":"Unix timestamp of the latest successful refresh","type":"integer"},"status":{"description":"Current MCP tool refresh status","enum":["ERROR","PENDING","READY"],"type":"string"},"tool_count":{"description":"Number of cached remote MCP tools","type":"integer"}},"required":["status"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorMtlsConfig":{"description":"mTLS certificate metadata and PEM content (private key is never exposed)","properties":{"ca_certificate":{"description":"PEM-encoded CA certificate chain (public, safe to expose)","type":"string"},"client_certificate":{"description":"PEM-encoded client certificate (public, safe to expose)","type":"string"},"expires_at":{"description":"Unix timestamp of certificate expiry","type":"integer"},"fingerprint":{"description":"SHA-256 fingerprint of the certificate","type":"string"},"has_certificate":{"description":"Whether an mTLS certificate is configured","type":"boolean"},"subject":{"description":"Certificate subject DN","type":"string"}},"required":["has_certificate"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorUserAuthInjectionConfig":{"description":"Configuration for injecting user auth tokens into tool requests","properties":{"field_name":{"description":"Field name for the injected token (e.g. X-User-Token)","type":"string"},"location":{"description":"Where to inject the token","enum":["body","headers","path","query"],"type":"string"},"prefix":{"description":"Prefix for the token value (e.g. Bearer )","type":"string"}},"required":["field_name","location","prefix"],"type":"object"},"knowledge_connectors.StandardError":{"description":"Standard error response for Meta Business Agent endpoints","properties":{"detail":{"description":"Human-readable explanation of the error","type":"string"},"status":{"description":"HTTP status code","type":"integer"},"title":{"description":"Short, human-readable summary of the problem","type":"string"},"type":{"description":"A URI reference identifying the problem type","type":"string"}},"type":"object"}}},"paths":{"/agent_connectors/{connector_id}/upsertApiKey":{"post":{"description":"Set or rotate the API key credentials for this connector. If credentials already exist, they are replaced and the connection is re-established. The credential payload is required; this endpoint will not delete credentials. At least one of headers, query_params, or body_params must contain a populated entry; the request fails with HTTP 400 if api_key_config is null or missing. To remove an API key layer, delete the connector or change its auth type via the update endpoint instead.","operationId":"post-agent-connectors-upsert-apikey","parameters":[{"description":"Meta Business Agent API version","in":"header","name":"X-API-Version","schema":{"enum":["2.0.0"],"type":"string"}},{"description":"The unique identifier of the connector","in":"path","name":"connector_id","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorUpsertApiKeyRequest","summary":"requestBody","description":"API key credentials to upsert"}}},"description":"API key credentials to upsert","required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorResponse"}}},"description":"The updated connector with API key metadata"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/knowledge_connectors.StandardError"}}},"description":"Bad request"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/knowledge_connectors.StandardError"}}},"description":"Unauthorized"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/knowledge_connectors.StandardError"}}},"description":"Forbidden"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/knowledge_connectors.StandardError"}}},"description":"Not found"},"429":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/knowledge_connectors.StandardError"}}},"description":"Too many requests"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/knowledge_connectors.StandardError"}}},"description":"Server error"}},"summary":"Upsert API key credentials for a connector","tags":["Knowledge - Connectors"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.360dialog.com/docs/mba/api-ref/knowledge-connectors/upsert-api-key-credentials-for-a-connector.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
