---
docId: doc_585dd370af58467fa710d27c9ed714b6
title: Goals
description: "Define when a campaign conversation meets a goal."
api:
  group: campañas
  auth: bearer
  operations:
    - operationId: listCampaignGoals
      method: GET
      path: '/v1/campaigns/{campaignId}/goals'
      postmanName: List campaign goals
    - operationId: createCampaignGoal
      method: POST
      path: '/v1/campaigns/{campaignId}/goals'
      postmanName: Create a campaign goal
    - operationId: updateCampaignGoal
      method: PATCH
      path: '/v1/campaigns/{campaignId}/goals/{goalId}'
      postmanName: Update a campaign goal
---

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

# Goals

A goal defines what should happen in a campaign conversation, such as "Asked for a quote". The [report](/api-reference/campaigns/results#report) counts conversations that meet the criteria.

**Before you start:** the campaign `id` in the `CAMPAIGN_ID` variable.

## Create a goal

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

```bash
curl -X POST https://api.platic.ai/v1/campaigns/$CAMPAIGN_ID/goals \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Asked for a quote", "criteria": "The customer asks for a price." }'
```

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

```ts
const campaignId = process.env.CAMPAIGN_ID!;
const goal = await platic.campaigns.goals.create(campaignId, {
  name: "Asked for a quote",
  criteria: "The customer asks for a price.",
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

In the Spring sale campaign, count it as achieved when the customer asks for a price or a quote.

</Ways.Say>

Your assistant uses `create_campaign_goal`.

</Ways.Way>
</Ways>

If a goal with that name already exists, the response is `200` with that goal and `alreadyExisted: true`. Update that goal to change its criteria.

## List reference

| Parameter | In | Type | Description | Required |
|-----------|----|------|-------------|----------|
| `campaignId` | path | string | The campaign `id` | ✓ |
| `workspace` | query | string | The campaign's workspace, if the credential covers several | — |

`data` carries all the campaign's goals, without pagination:

```json
{
  "status": "success",
  "data": [
    { "id": "gq3Lm8Xp", "name": "Asked for a quote", "criteria": "The customer asks for a price.", "status": "active" }
  ]
}
```

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | `INVALID_REQUEST` | The credential covers several workspaces and `workspace` is missing or is not one of them |

See [Errors](/api-reference/errors) for the full shape of an error.

## Create reference

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `name` | string | A short, clear name, up to 120 characters | ✓ |
| `criteria` | string | How you can tell in the conversation that it was achieved, up to 2,000 characters | ✓ |

It answers `201` with the new goal, or `200` with the one that already existed:

```json
{
  "status": "success",
  "message": "Goal created",
  "data": {
    "id": "gq3Lm8Xp",
    "name": "Asked for a quote",
    "criteria": "The customer asks for a price.",
    "status": "active",
    "alreadyExisted": false
  }
}
```

## Update reference

Send `name`, `criteria`, or both, using the same limits as for creation. Get the `goalId` by listing goals. The response contains the updated goal.

| Status | `details.code` | When |
|--------|----------------|------|
| `400` | — | Neither `name` nor `criteria` arrived, or they go over the limit |
| `404` | `GOAL_NOT_FOUND` | The campaign has no goal with that `id` |
