---
docId: doc_3246f93482514fe9a822e156c5aecc73
title: Publish a function
description: "Verify and publish a new version for connected agents."
api:
  group: herramientas/funciones-personalizadas
  auth: bearer
  operations:
    - operationId: publishFunction
      method: POST
      path: '/v1/tools/functions/{functionId}/publish'
      postmanName: Publish a function
---

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

# Publish a function

Verify the draft and deploy it as a new fixed version. The function becomes `enabled` in the workspace catalog. Connected agents use that version immediately.

## Example

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

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

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

```ts
await platic.tools.functions.publish("fn_123", { notes: "First version" });
```

</Ways.Way>
</Ways>

## Path parameters

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

## Request body

Optional.

```json
{
  "notes": "First version"
}
```

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `notes` | string | What changed in this version, up to 500 characters | — |

## Response

`data.function` has the complete function, with the fields of [Get a function](/api-reference/custom-functions/get#response-fields).

```json
{
  "status": "success",
  "message": "Version 1 published",
  "data": {
    "version": 1,
    "toolId": "Hk2s9QmXc1",
    "function": {
      "id": "Hk2s9QmXc1",
      "name": "tax_id_lookup",
      "status": "enabled",
      "liveVersion": 1,
      "toolName": "fn_tax_id_lookup",
      "toolId": "Hk2s9QmXc1",
      "nextStep": "Live (version 1). Connect it to an agent with PUT /v1/agents/{agentId}/tools/Hk2s9QmXc1; run it by hand with POST /v1/tools/functions/Hk2s9QmXc1/run. Changes to source stay in the draft until you publish again."
    }
  }
}
```

Some `function` fields are left out of the example.

## Response fields

| Field | Type | Description |
|-------|------|-------------|
| `version` | integer | The new version's number |
| `toolId` | string \| null | The ID to [connect a tool](/api-reference/agents/tools/connect) |
| `function` | object | The function, already `enabled` and with `liveVersion` updated |

## Errors

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | `notes` is over 500 characters. `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 |
| `422` | `VALIDATION_FAILED` | The draft does not pass verification. `details.issues` has each problem |
| `429` | `LIMIT_REACHED` | The limit of 50 deployments per day was exceeded. `details.resetAt` says when it frees up |

## Notes

- After publishing, use `toolId` to [connect the tool](/api-reference/agents/tools/connect) to an agent.
- Each version stores the code, `allowedDomains`, `timeoutSeconds` and `secretSlots` it was published with.
- If something goes wrong, [go back to an earlier version](/api-reference/custom-functions/restore-version) immediately.
- Publishing a paused function also turns it back on.
