External APIs
An external API is an origin that this project's workflows are allowed to call with the External API node. For the steps to register an API that uses OAuth2, refer to How to register an API that uses OAuth2.
Registration
| Field | Rule |
|---|---|
| Display name | Required. 1 to 120 characters. For you only; it does not go out with the request. |
| Origin | Required. The scheme, the host and the optional port, with no path, query, fragment or sign-in details. http or https only, on port 80 or 443. Must not point at a private, loopback or link-local address. One live registration per origin per project. |
| Credential | None, an authorization header, or an OAuth2 credential. Each secret is encrypted and is never returned. |
An authorization header is a header name and a value. The dashboard shows the header name and a mask. An OAuth2 credential gets an access token for each call. Refer to OAuth2 credential. When you set one kind of credential, Picked removes the other kind.
On a registration with an OAuth2 credential, the dashboard does not show the authorization header. Remove the OAuth2 credential before you set a header.
To change an origin, delete the registration and register the new origin. The origin is the registration's identity.
A preset sets the display name, the origin and an OAuth2 credential for a provider. Refer to OAuth2 credential.
OAuth2 credential
An OAuth2 credential gets an access token from the provider's token URL. Picked sends the header scheme, a space and the access token in the header with each request.
| Setting | Default | Rule |
|---|---|---|
| Grant | Refresh token | Refresh token or Client credentials. |
| Token URL | — | Required. An https URL with no fragment. The query must not contain grant_type, client_id, client_secret, refresh_token or code. Picked checks the URL as it checks an origin. Picked does not register its origin. |
| Client ID | — | Required. 1 to 512 characters. |
| Client secret | — | Required. Encrypted, and never returned. When you edit the credential, an empty field keeps the stored client secret. If you change the token URL, the client ID or the client authentication, enter the client secret again. |
| Refresh token | — | Required for the refresh token grant. The client credentials grant does not use one. Encrypted, and never returned. When you edit the credential, an empty field keeps the stored refresh token. If you change the token URL, the client ID or the client authentication, enter the refresh token again. |
| Client authentication | Form body | The client ID and the client secret go in the form body, or in an Authorization: Basic header. |
| Token parameters | None | Up to 20 more form parameters, such as scope. grant_type, client_id, client_secret, refresh_token and code are not permitted. |
| Header name | Authorization | The header that holds the access token. |
| Header scheme | Bearer | The word before the access token, such as Zoho-oauthtoken. No spaces. |
| 401 rule | None | A path in the JSON body of a 401 answer, and 1 to 20 values at that path that show an expired token. Put a dot between the parts of the path, for example code or data.0.code. A part that is a number identifies an item in a list. With no rule, each 401 shows an expired token. |
The Zoho CRM preset sets the display name Zoho CRM and the origin of the API for the
region, such as https://www.zohoapis.com.au. It also sets an OAuth2 credential. The
credential has the token URL for the region, Form body, Zoho-oauthtoken, and a 401 rule
of code with the value INVALID_TOKEN. On the page of a registered external API, the preset sets only the
OAuth2 credential.
Access tokens
- Picked sends the token request as a
POSTwith a form body, so no secret is in a URL. - Picked uses an access token until 60 seconds before it expires.
- Refresh credentials on the page of the external API gets a new access token immediately. The page then shows the time of the last refresh, or the reason for the failure.
- Picked reads the lifetime from
expires_in_sec, or else fromexpires_in. Picked keeps a token with no lifetime for one hour. - Picked counts an answer as a success when its JSON body has an
access_token, for all statuses. - A
refresh_tokenin the answer replaces the stored refresh token. - One token request at a time runs for each credential. Other calls use the token that it gets.
- After a token request fails with
credential_refresh_failed, Picked sends no token request for 60 seconds. Calls in that time fail withcredential_refresh_failed. - Picked uses a stored access token for all values of
timeoutMs. - The token request, and the wait for a token request of another call, use time from the
node's
timeoutMs. Each stops while 5 seconds remain. Picked starts a token request only when 6 seconds or more remain. A token request stops after 10 seconds. - When the node's time stops a token request, other calls can send a token request immediately.
A 401 answer
Picked gets a new token and sends the request again when these are all true:
- The API answered 401.
- The token is older than 60 seconds.
- The credential has no 401 rule, or the rule applies to the body of the answer.
The second request has the same Idempotency-Key, if the node sends one. Its answer is the
result of the node.
If Picked cannot get a new token, the node fails with credential_rejected or
credential_refresh_failed. Then nodes.<node-id>.status, ok and body keep the 401
answer.
Node arguments
| Argument | Default | Rule |
|---|---|---|
method | — | Required. GET, HEAD, POST, PUT, PATCH or DELETE. |
url | — | Required. The full address. Its origin must be registered to this project. |
headers | none | A JSON object of headers to send. Picked refuses a credential here when you save. |
body | none | The JSON body. Used by POST, PUT and PATCH. |
timeoutMs | 10000 | 1000 to 30000. The time that the whole call has, with every retry. |
retry | on for GET, HEAD, PUT and DELETE; off for POST and PATCH | Whether to send the request again after a failed connection, an unknown host, or a status of 408, 429 or 500 to 599. |
failOnErrorStatus | on | Whether a status outside 200 to 299 fails the node. |
recordBody | on | Whether to record the answer's body. |
idempotencyKey | off | Whether to send the Idempotency-Key header. Set it to on when the API accepts it. |
Output
| Name | Value |
|---|---|
status | The HTTP status. |
ok | True for a status from 200 to 299. |
body | The parsed JSON answer, or null when it is not JSON or was not recorded. |
bodyTruncated | True when the answer was too large to record in full. |
durationMs | The time the call took. |
Limits
- The request body is limited to 1 MiB.
- The recorded answer is limited to 1 MiB. A larger answer sets
bodyTruncated. - Picked records the status that asks the caller to redirect. Picked does not go to the new address.
- Picked sends a request three times at most. Picked waits longer before each retry, and
waits for the time that a
Retry-Afterheader gives. - A timeout uses all of
timeoutMs, so Picked does not send the request again after a timeout.
Errors
When the node fails, the run stops at the node. If the call fails and an edge leaves the node's error exit, the run continues on that edge. These failures stop the run at the node, with or without that edge:
- A required argument has no value.
- An argument has a value that the tool does not accept. For example, the value has the
wrong type,
methodis not one of the six methods, ortimeoutMsis not from 1000 to 30000. - A template cannot be rendered.
- The workflow does not have a scope that the tool needs.
- An error occurs in Picked.
A later node reads why the call failed from nodes.<node-id>.error:
| Field | Value |
|---|---|
code | http_failed. |
message | The node, the tool and the message from the table below. |
reason | The reason from the table below. |
retryable | True when the same request can pass at a later time. |
status | The HTTP status, for the reason error_status. Also for a credential reason after a 401 answer. |
After an error status, nodes.<node-id>.status, ok and body also keep the answer.
| Reason | Message ends with | Retryable | When |
|---|---|---|---|
error_status | the API answered <status> | For 408, 429 and 500 to 599 | The status was outside 200 to 299, and failOnErrorStatus is on. |
timeout | no answer within the node's timeout | Yes | Nothing answered within timeoutMs. |
transport | the request could not be delivered | Yes | The connection failed. |
unresolvable | the destination hostname did not resolve | Yes | No address was found for the host. |
refused | the destination was refused | No | The URL points at a private, loopback or link-local address. |
refused | no external API is registered for <origin> | No | The URL's origin has no live registration in this project. |
request_too_large | the request body is over 1 MiB | No | The body is larger than the limit. |
invalid_request | the request is not one the tool can send | No | The arguments do not make a valid request. |
invalid_request | the URL is not one the tool can send | No | The tool cannot send to the URL. |
invalid_headers | The header that Picked refused | No | A header name or value is not valid for HTTP. |
credential_unavailable | the credential for this external API is unavailable | No | Picked cannot read a secret of the registration's credential. |
credential_rejected | the token endpoint refused this external API's credential | No | The token endpoint answered invalid_client, invalid_grant, invalid_code, invalid_client_secret or unauthorized_client. |
credential_refresh_failed | no access token could be fetched for this external API | Yes | The token endpoint did not answer in time, or Picked cannot reach it. Or the token endpoint answered with no token, or a token request failed less than 60 seconds before. Or the node's time ran out. |
Picked also refuses a workflow when you save it if a node holds a credential in
headers. Register the external API, and put the credential on the registration.
API and MCP
You can also do this task with the Management API, the MCP server, or code that you send to picked_run.
| Task | GraphQL | MCP tool | Run |
|---|---|---|---|
| Register an external API | externalApiCreate | None | None |
| Set or replace the authorization header | externalApiAuthHeaderSet | None | None |
| Get a new OAuth2 access token | externalApiOAuth2Refresh | None | None |
| Delete a registration | externalApiDelete | None | None |
| Set the arguments of an External API node | workflowGraphUpdate | update_workflow_graph | tools.update_workflow_graph({ workflow_id, update_nodes }) |
The external API mutations refuse an API key. Use the access token of a user.
Related
- About apps — when to use an app in place of an external API.
