ApiKey
Overview
Section titled “Overview”Many services issue an API key that every request sends in a header. A connector of type ApiKey stores the key encrypted, together with the header and prefix the service expects. How to create a connector is described under None.
You create the key at the service itself, usually under Settings → API or Profile → API keys.
Structure
Section titled “Structure”| Field | Meaning |
|---|---|
| API key | the key (stored encrypted) |
| Header | name of the header, default Authorization; e.g. x-api-key |
| Scheme | prefix before the key when the header is Authorization, e.g. Bearer or token |
| Base URL | address of the API, for Test and as {{connector.<Name>.BaseUrl}} |
Test sends the key the way header and scheme define: Authorization: Bearer <key>, or x-api-key: <key>.
The HTTPRequest action only gets the connector’s name ("Connector": "<Name>") and sends the key exactly as Test does; a Url such as /orders is appended to the base URL. If you prefer to set the header in the action, take only the key from the connector:
| The service expects | In the action |
|---|---|
Authorization: Bearer <key> |
"AuthType": "Bearer", "AuthToken": "{{connector.<Name>.ApiKey}}" |
X-API-KEY: <key> |
"AuthType": "ApiKey", "AuthToken": "{{connector.<Name>.ApiKey}}" |
| another header | "Headers": { "x-api-key": "{{connector.<Name>.ApiKey}}" } |
Example
Section titled “Example”Connector OpenAI from the OpenAI template: header Authorization, scheme Bearer, base URL https://api.openai.com/v1/. Request a summary of the PDF text that was read:
{ "Type": "HttpRequest", "Name": "Summarize", "Parameters": { "Url": "/chat/completions", "Method": "POST", "Connector": "OpenAI", "TimeoutSeconds": 60, "Body": { "model": "gpt-4o-mini", "messages": [ { "role": "user", "content": "Summarize this text in three sentences:\n{{FileContent}}" } ] } }}The answer is in {{Summarize.Response.Body.choices.0.message.content}}. Another example with an API key is Odoo Contacts.
