Bind a secret to a function
SDK platic.tools.functions.bindSecret()
Bind an existing secret to a slot in secretSlots. Use this when a slot in secrets[] is missing. Send the secret's id, not its value.
Example
curl -X POST "https://api.platic.ai/v1/tools/functions/$FUNCTION_ID/secrets" \
-H "Authorization: Bearer $PLATIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"slot": "API_KEY",
"secretId": "'"$SECRET_ID"'"
}' await platic.tools.functions.bindSecret("fn_123", { slot: "API_KEY", secretId: "sec_123" }); Path parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
functionId | string | Function ID | ✓ |
Request body
{
"slot": "API_KEY",
"secretId": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c"
} | Field | Type | Description | Required |
|---|---|---|---|
slot | string | A declared slot, like API_KEY. secret:API_KEY is also accepted | ✓ |
secretId | string | Secret ID, from List secrets or Create a secret | ✓ |
Response
data has the complete function, with the fields of Get a function. The slot ends up in bound.
{
"status": "success",
"message": "Secret bound",
"data": {
"id": "Hk2s9QmXc1",
"name": "tax_id_lookup",
"status": "draft",
"toolName": "fn_tax_id_lookup",
"toolId": null,
"secrets": [
{
"slot": "API_KEY",
"origin": "https://api.example.com",
"state": "bound",
"secretId": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c"
}
],
"nextStep": "Test it with POST /v1/tools/functions/Hk2s9QmXc1/test, then publish it."
}
} Some fields are left out of the example.
Errors
| Status | details.code | When |
|---|---|---|
400 | INVALID_REQUEST | slot or secretId is missing, or the slot is not declared. details.issues has the list of problems |
403 | FORBIDDEN or INSUFFICIENT_SCOPE | The credential cannot use secrets or does not have write access to Integrations |
404 | NOT_FOUND | The function or the secret does not exist in this workspace |
501 | FUNCTION_SECRETS_UNAVAILABLE | Binding secrets is not available at the moment |
Notes
- The secret is authorized only for that slot's
origin. Platica puts it inhttp.fetchcalls to that origin; the code only sees a placeholder. - Binding another secret to the same slot replaces the previous one.
- If you later change
allowedDomainsorsecretSlotswith Update a function, bind the secrets again. - The same secret can be bound to several functions and to other tools.