> 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.

```json
{"openapi":"3.1.0","info":{"title":"Business Agent API","version":"1.49.1"},"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":{"items":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorApiKeyParam"},"type":"array","uniqueItems":false},"headers":{"items":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorApiKeyParam"},"type":"array","uniqueItems":false},"query_params":{"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":{"type":"string"},"prefix":{"type":"string"},"value":{"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":{"enum":["OAUTH2","OAUTH2_CLIENT_CREDENTIALS","API_KEY","BASIC","CUSTOM","NONE"],"type":"string"},"base_url":{"type":"string"},"connection_status":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorConnectionStatus"},"description":{"type":"string"},"id":{"type":"string"},"mtls_config":{"$ref":"#/components/schemas/knowledge_connectors.BizAIOmniChannelConnectorMtlsConfig"},"name":{"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":{"type":"string"},"client_secret":{"type":"string"},"scopes_to_request":{"items":{"type":"string"},"type":"array","uniqueItems":false},"token_request_content_type":{"type":"string"},"token_url":{"type":"string"}},"required":["client_id","client_secret","scopes_to_request","token_url"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorConnectionStatus":{"description":"Connection status information","properties":{"error_message":{"type":"string"},"status":{"enum":["PENDING_OAUTH","ACTIVE","EXPIRED","ERROR"],"type":"string"}},"required":["status"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorMtlsConfig":{"description":"mTLS certificate metadata and PEM content (private key is never exposed)","properties":{"ca_certificate":{"type":"string"},"client_certificate":{"type":"string"},"expires_at":{"type":"integer"},"fingerprint":{"type":"string"},"has_certificate":{"type":"boolean"},"subject":{"type":"string"}},"required":["has_certificate"],"type":"object"},"knowledge_connectors.BizAIOmniChannelConnectorUserAuthInjectionConfig":{"description":"Configuration for injecting user auth tokens into tool requests","properties":{"field_name":{"type":"string"},"location":{"enum":["body","headers","path","query"],"type":"string"},"prefix":{"type":"string"}},"required":["field_name","location","prefix"],"type":"object"},"knowledge_connectors.StandardError":{"description":"Standard error response for Meta Business Agent endpoints","properties":{"detail":{"type":"string"},"status":{"type":"integer"},"title":{"type":"string"},"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.","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"},"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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
