---
docId: doc_b043d6e3b67a452b90f571e3e154f4fb
title: Run a function
description: "Manually run a function's published version."
api:
  group: herramientas/funciones-personalizadas
  auth: bearer
  operations:
    - operationId: runFunction
      method: POST
      path: '/v1/tools/functions/{functionId}/run'
      postmanName: Run a function
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Run a function

Run the published version with `input`, as an agent would. The result is recorded as a manual execution.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl -X POST "https://api.platic.ai/v1/tools/functions/$FUNCTION_ID/run" \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": { "taxId": "XAXX010101000" }
}'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.tools.functions.run("fn_123", { input: { rfc: "XAXX010101000" } });
```

</Ways.Way>
</Ways>

<Note type="important">

The execution makes real HTTP calls. Use it to check a function. It does not provide general-purpose compute, background runs, scheduled runs, or webhook-triggered runs.

</Note>

## Path parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| `functionId` | string | Function ID | ✓ |

## Request body

```json
{
  "input": { "taxId": "XAXX010101000" }
}
```

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `input` | object | Input that meets the published version's `input` schema. Up to 256 KB | — |

Do not send `secrets`: the execution uses the secrets bound to the function and answers `400` if the body has them.

## Response

It has the same fields as [Test a function](/api-reference/custom-functions/test#response-fields). `version` is the published version's number. An execution that fails inside the code is also a `200`, with `ok: false` and `error`.

```json
{
  "status": "success",
  "data": {
    "ok": true,
    "output": { "found": true, "name": "EXAMPLE COMPANY INC" },
    "durationMs": 412,
    "logs": ["info response {\"status\":200}"],
    "httpCalls": [
      { "method": "POST", "host": "api.example.com", "status": 200, "durationMs": 380 }
    ],
    "runId": "run_8d1f",
    "version": 1,
    "nextStep": "It ran. The run is in the function's runs."
  }
}
```

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | The body fails validation or has `secrets`. `details.issues` has the list of problems |
| `403` | `FORBIDDEN` or `INSUFFICIENT_SCOPE` | The credential does not have write access to Integrations |
| `404` | `NOT_FOUND` | The function does not exist in this workspace |
| `409` | `NOT_PUBLISHED` | The function does not have a published version yet |
| `409` | `PAUSED` | The function is paused |
| `429` | `LIMIT_REACHED` | The call limit was exceeded: 60 per minute per function, 5,000 per day or 50,000 per month per workspace. `details.resetAt` says when it frees up |

## Notes

- It counts against the same call quota agents use.
- The execution stays in the [executions](/api-reference/custom-functions/executions) with `trigger: "manual"`.
- An unbound secret answers `ok: false` with `SECRET_MISSING`. Bind it with [Bind a secret](/api-reference/custom-functions/bind-secret).
