# Upsert sales pipeline

Create or update a sales pipeline by a permanent external reference. Matching is exact within the workspace, resource type and ownership scope. Supplied fields replace their values; omitted fields stay unchanged. Deleted records are not recreated.

POST https://api.brigg.app/v1/operations/customers.UpsertSalesPipeline

## Access & visibility

Allow `customers.UpsertSalesPipeline` on your API key. Resource read permissions: `core:SalesPipeline`. Resource write permissions: `core:SalesPipeline`.

**Workspace access by default.** Private member data requires [approved member delegation](https://developer.brigg.app/authentication#member-delegation) through `Brigg-Act-As`; the key supplies permissions while private ownership and project boundaries remain enforced.

[Set up authentication](https://developer.brigg.app/authentication) · [Choose permissions](https://developer.brigg.app/permissions)

## Request fields

Send a JSON object with the following fields. Required fields must be included; omit optional fields you do not need.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | [SalesPipeline](#salespipeline-request-data) | Yes | The record's fields. |
| `private` | boolean | No | Defaults to false: the record is shared with the workspace. True assigns private ownership to the approved acting member and requires member delegation. This is independent of created_by provenance. |
| `external_ref` | [object](#request-external-ref) | Yes | Permanent, case-sensitive source identity within this workspace, resource type and private/workspace scope. It is independent of API key rotation and retry receipt expiry. |

### SalesPipeline · request.data

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | Yes | Name of the sales pipeline. |
| `stages` | array of [object](#request-data-stages) | No | Sales stages in funnel order. Keep stage IDs stable: deals refer to them. Exactly one won and one lost stage appear last; probability is an integer percentage from 0 to 100 for weighted sales value. |
| `is_default` | boolean | No | Whether this is the workspace's default sales pipeline. |

### request.data.stages[]

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | Stable stage ID referenced by deals. Keep it when changing the label. |
| `label` | string | Yes | Human-readable stage name. |
| `kind` | string | Yes | Whether this stage is open, won or lost. Allowed: `"open"`, `"won"`, `"lost"`. |
| `probability` | number | No | Integer percentage from 0 to 100 used for weighted sales value. |
| `tone` | string | No | Display color token for the stage. Allowed: `"gray"`, `"blue"`, `"violet"`, `"peach"`, `"soon"`, `"accent"`, `"warn"`. |

### request.external_ref

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `namespace` | string | Yes | A stable name for the source system, such as crm-production. At least 1 character. |
| `id` | string | Yes | The record ID in that source system. At least 1 character. |

## Sync with a permanent external reference

Choose a stable `external_ref.namespace` for your source system and put its record ID in `external_ref.id`. Matching is case-sensitive and scoped to this workspace, resource type and private/workspace ownership. The reference survives API key replacement and the 30-day retry receipt window. It does not match records by email or name.

Send the required create fields each time. A missing reference creates a record; an existing reference updates only supplied fields and preserves everything else. `created` tells you which happened. Use the same idempotency key when retrying a lost response and a new key for a later source change. Concurrent calls cannot create duplicate records. A deleted or inaccessible match is refused; the operation does not restore it or make a replacement.

Use the returned `item.id` with the regular update operation when you need `unset` or a conditional `expected` edit. Changing `private` chooses a different ownership scope; it does not transfer an existing record.

## Response

Returns **200 OK** with a JSON body.

Record metadata sits outside `data`. Timestamps `created_at` and `updated_at` are Unix milliseconds. Optional business fields may be absent; absence does not mean false or zero. A field accepts null only when its type includes null.
| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `item` | [SalesPipelineRecord](#salespipelinerecord-response-item) | Yes | The requested record, including its metadata and data fields. |
| `created` | boolean | Yes | True when this external reference created a record; false when it matched an existing record. |

### SalesPipelineRecord · response.item

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | Stable core:SalesPipeline record ID. Keep this top-level value when reading or referring to this record. Available actions are linked under Next steps; an ID does not imply the resource can be edited. |
| `created_at` | number | Yes | Time the record was created, in Unix milliseconds. |
| `updated_at` | number | Yes | Time the record most recently changed, in Unix milliseconds. Use with overlapping windows for incremental reads. |
| `created_by` | string or null | Yes | Account that originally created the record, or null for a workspace/system-originated record. This is provenance, not its current owner or a Person record ID. |
| `private` | boolean | Yes | True for a member-owned private record. An API key needs approved delegation to that owner; false alone does not bypass resource grants or other access rules. |
| `data` | [SalesPipeline](#salespipeline-response-item-data) | Yes | The record's fields. |

### SalesPipeline · response.item.data

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | Yes | Name of the sales pipeline. |
| `stages` | array of [object](#response-item-data-stages) | No | Sales stages in funnel order. Keep stage IDs stable: deals refer to them. Exactly one won and one lost stage appear last; probability is an integer percentage from 0 to 100 for weighted sales value. |
| `is_default` | boolean | No | Whether this is the workspace's default sales pipeline. |

### response.item.data.stages[]

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | Stable stage ID referenced by deals. Keep it when changing the label. |
| `label` | string | Yes | Human-readable stage name. |
| `kind` | string | Yes | Whether this stage is open, won or lost. Allowed: `"open"`, `"won"`, `"lost"`. |
| `probability` | number | No | Integer percentage from 0 to 100 used for weighted sales value. |
| `tone` | string | No | Display color token for the stage. Allowed: `"gray"`, `"blue"`, `"violet"`, `"peach"`, `"soon"`, `"accent"`, `"warn"`. |

## Errors & retries

Set `BRIGG_REQUEST_ID` once for each logical action. The samples send it as `Idempotency-Key`. Reuse the same value and body on retries, including after a timeout; a missing response does not prove the action failed.

For rate limits, follow the server’s retry guidance and back off. See [HTTP errors](https://developer.brigg.app/http#errors) and [safe retries and limits](https://developer.brigg.app/reliability).

| HTTP status | Code | What to do |
| --- | --- | --- |
| 400 | `invalid_json` | Send a JSON object with Content-Type: application/json. |
| 400 | `invalid_input` | Check the request fields and types. Supply a stable Idempotency-Key containing 1–200 characters. |
| 401 | `invalid_key` | The workspace API key is missing, invalid or revoked. |
| 403 | `forbidden` | Check the key’s operation and resource grants. If Brigg-Act-As is supplied, the key must be authorized to delegate to that member. |
| 404 | `not_found` | The requested operation or resource is not available to this credential. |
| 429 | `rate_limited` | Wait for Retry-After before retrying. Reuse the original Idempotency-Key. |

## Next steps

- [List sales pipelines](https://developer.brigg.app/reference/customers/ListSalesPipelines)
- [Get sales pipeline](https://developer.brigg.app/reference/customers/GetSalesPipeline)
- [Create sales pipeline](https://developer.brigg.app/reference/customers/CreateSalesPipeline)
- [Update sales pipeline](https://developer.brigg.app/reference/customers/UpdateSalesPipeline)
- [Delete sales pipeline](https://developer.brigg.app/reference/customers/DeleteSalesPipeline)

[Download OpenAPI](https://developer.brigg.app/openapi.json) · [Versioning & retirement](https://developer.brigg.app/versioning)

## Examples

### First sync

Fictional values. Replace IDs and business details with values from your workspace.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/customers.UpsertSalesPipeline' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $BRIGG_REQUEST_ID" \
  --data-raw '{
  "external_ref": {
    "namespace": "crm-production",
    "id": "customer-1042"
  },
  "data": {
    "name": "Sales pipeline",
    "is_default": true,
    "stages": [
      {
        "id": "lead",
        "label": "Lead",
        "kind": "open",
        "probability": 10
      },
      {
        "id": "won",
        "label": "Won",
        "kind": "won",
        "probability": 100
      },
      {
        "id": "lost",
        "label": "Lost",
        "kind": "lost",
        "probability": 0
      }
    ]
  }
}'
```

#### TypeScript


```typescript
const requestId = process.env.BRIGG_REQUEST_ID;
if (!requestId) throw new Error("Set BRIGG_REQUEST_ID once per action and reuse it on retries.");

const response = await fetch("https://api.brigg.app/v1/operations/customers.UpsertSalesPipeline", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": requestId, // Create once per action; reuse on retries.
  },
  body: JSON.stringify({
    "external_ref": {
      "namespace": "crm-production",
      "id": "customer-1042"
    },
    "data": {
      "name": "Sales pipeline",
      "is_default": true,
      "stages": [
        {
          "id": "lead",
          "label": "Lead",
          "kind": "open",
          "probability": 10
        },
        {
          "id": "won",
          "label": "Won",
          "kind": "won",
          "probability": 100
        },
        {
          "id": "lost",
          "label": "Lost",
          "kind": "lost",
          "probability": 0
        }
      ]
    }
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

request_id = os.environ["BRIGG_REQUEST_ID"]  # Reuse for retries of this action.
payload = {
  "external_ref": {
    "namespace": "crm-production",
    "id": "customer-1042"
  },
  "data": {
    "name": "Sales pipeline",
    "is_default": True,
    "stages": [
      {
        "id": "lead",
        "label": "Lead",
        "kind": "open",
        "probability": 10
      },
      {
        "id": "won",
        "label": "Won",
        "kind": "won",
        "probability": 100
      },
      {
        "id": "lost",
        "label": "Lost",
        "kind": "lost",
        "probability": 0
      }
    ]
  }
}
request = Request(
    "https://api.brigg.app/v1/operations/customers.UpsertSalesPipeline",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Idempotency-Key": request_id,  # Create once per action; reuse on retries.
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "item": {
    "id": "e_salespipeline_example",
    "created_at": 1791276900000,
    "updated_at": 1791280800000,
    "created_by": "a_jamie",
    "private": false,
    "data": {
      "name": "Sales pipeline",
      "is_default": true,
      "stages": [
        {
          "id": "lead",
          "label": "Lead",
          "kind": "open",
          "probability": 10
        },
        {
          "id": "won",
          "label": "Won",
          "kind": "won",
          "probability": 100
        },
        {
          "id": "lost",
          "label": "Lost",
          "kind": "lost",
          "probability": 0
        }
      ]
    }
  },
  "created": true
}
```

### Later sync

The same external reference returns the same record ID. Use a new idempotency key for a later source change.
#### cURL


```sh
curl 'https://api.brigg.app/v1/operations/customers.UpsertSalesPipeline' \
  -H "Authorization: Bearer $BRIGG_API_KEY" \
  -H 'Content-Type: application/json' \
  -H "Idempotency-Key: $BRIGG_REQUEST_ID" \
  --data-raw '{
  "external_ref": {
    "namespace": "crm-production",
    "id": "customer-1042"
  },
  "data": {
    "name": "Sales pipeline",
    "is_default": true,
    "stages": [
      {
        "id": "lead",
        "label": "Lead",
        "kind": "open",
        "probability": 10
      },
      {
        "id": "won",
        "label": "Won",
        "kind": "won",
        "probability": 100
      },
      {
        "id": "lost",
        "label": "Lost",
        "kind": "lost",
        "probability": 0
      }
    ]
  }
}'
```

#### TypeScript


```typescript
const requestId = process.env.BRIGG_REQUEST_ID;
if (!requestId) throw new Error("Set BRIGG_REQUEST_ID once per action and reuse it on retries.");

const response = await fetch("https://api.brigg.app/v1/operations/customers.UpsertSalesPipeline", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BRIGG_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": requestId, // Create once per action; reuse on retries.
  },
  body: JSON.stringify({
    "external_ref": {
      "namespace": "crm-production",
      "id": "customer-1042"
    },
    "data": {
      "name": "Sales pipeline",
      "is_default": true,
      "stages": [
        {
          "id": "lead",
          "label": "Lead",
          "kind": "open",
          "probability": 10
        },
        {
          "id": "won",
          "label": "Won",
          "kind": "won",
          "probability": 100
        },
        {
          "id": "lost",
          "label": "Lost",
          "kind": "lost",
          "probability": 0
        }
      ]
    }
  }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.error} — ${result.message}`);
console.log(result);
```

#### Python


```python
import json
import os
from urllib.request import Request, urlopen
from urllib.error import HTTPError

request_id = os.environ["BRIGG_REQUEST_ID"]  # Reuse for retries of this action.
payload = {
  "external_ref": {
    "namespace": "crm-production",
    "id": "customer-1042"
  },
  "data": {
    "name": "Sales pipeline",
    "is_default": True,
    "stages": [
      {
        "id": "lead",
        "label": "Lead",
        "kind": "open",
        "probability": 10
      },
      {
        "id": "won",
        "label": "Won",
        "kind": "won",
        "probability": 100
      },
      {
        "id": "lost",
        "label": "Lost",
        "kind": "lost",
        "probability": 0
      }
    ]
  }
}
request = Request(
    "https://api.brigg.app/v1/operations/customers.UpsertSalesPipeline",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {os.environ['BRIGG_API_KEY']}",
        "Content-Type": "application/json",
        "Idempotency-Key": request_id,  # Create once per action; reuse on retries.
    },
    method="POST",
)
try:
    with urlopen(request) as response:
        print(json.load(response))
except HTTPError as error:
    print(error.code, json.load(error))
    raise
```

#### Response example


```json
{
  "item": {
    "id": "e_salespipeline_example",
    "created_at": 1791276900000,
    "updated_at": 1791280800000,
    "created_by": "a_jamie",
    "private": false,
    "data": {
      "name": "Sales pipeline",
      "is_default": true,
      "stages": [
        {
          "id": "lead",
          "label": "Lead",
          "kind": "open",
          "probability": 10
        },
        {
          "id": "won",
          "label": "Won",
          "kind": "won",
          "probability": 100
        },
        {
          "id": "lost",
          "label": "Lost",
          "kind": "lost",
          "probability": 0
        }
      ]
    }
  },
  "created": false
}
```

## JSON schemas


```json-schema-request
{
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the sales pipeline."
        },
        "stages": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Stable stage ID referenced by deals. Keep it when changing the label."
              },
              "label": {
                "type": "string",
                "description": "Human-readable stage name."
              },
              "kind": {
                "type": "string",
                "enum": [
                  "open",
                  "won",
                  "lost"
                ],
                "description": "Whether this stage is open, won or lost."
              },
              "probability": {
                "type": "number",
                "description": "Integer percentage from 0 to 100 used for weighted sales value."
              },
              "tone": {
                "type": "string",
                "enum": [
                  "gray",
                  "blue",
                  "violet",
                  "peach",
                  "soon",
                  "accent",
                  "warn"
                ],
                "description": "Display color token for the stage."
              }
            },
            "required": [
              "id",
              "label",
              "kind"
            ],
            "additionalProperties": false
          },
          "description": "Sales stages in funnel order. Keep stage IDs stable: deals refer to them. Exactly one won and one lost stage appear last; probability is an integer percentage from 0 to 100 for weighted sales value."
        },
        "is_default": {
          "type": "boolean",
          "description": "Whether this is the workspace's default sales pipeline."
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false,
      "description": "The record's fields.",
      "title": "SalesPipeline"
    },
    "private": {
      "type": "boolean",
      "description": "Defaults to false: the record is shared with the workspace. True assigns private ownership to the approved acting member and requires member delegation. This is independent of created_by provenance."
    },
    "external_ref": {
      "type": "object",
      "description": "Permanent, case-sensitive source identity within this workspace, resource type and private/workspace scope. It is independent of API key rotation and retry receipt expiry.",
      "properties": {
        "namespace": {
          "type": "string",
          "minLength": 1,
          "description": "A stable name for the source system, such as crm-production."
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "The record ID in that source system."
        }
      },
      "required": [
        "namespace",
        "id"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "external_ref",
    "data"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "external_ref": {
        "namespace": "crm-production",
        "id": "customer-1042"
      },
      "data": {
        "name": "Sales pipeline",
        "is_default": true,
        "stages": [
          {
            "id": "lead",
            "label": "Lead",
            "kind": "open",
            "probability": 10
          },
          {
            "id": "won",
            "label": "Won",
            "kind": "won",
            "probability": 100
          },
          {
            "id": "lost",
            "label": "Lost",
            "kind": "lost",
            "probability": 0
          }
        ]
      }
    }
  ]
}
```


```json-schema-response
{
  "type": "object",
  "properties": {
    "item": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Stable core:SalesPipeline record ID. Keep this top-level value when reading or referring to this record. Available actions are linked under Next steps; an ID does not imply the resource can be edited."
        },
        "created_at": {
          "type": "number",
          "description": "Time the record was created, in Unix milliseconds."
        },
        "updated_at": {
          "type": "number",
          "description": "Time the record most recently changed, in Unix milliseconds. Use with overlapping windows for incremental reads."
        },
        "created_by": {
          "type": [
            "string",
            "null"
          ],
          "description": "Account that originally created the record, or null for a workspace/system-originated record. This is provenance, not its current owner or a Person record ID."
        },
        "private": {
          "type": "boolean",
          "description": "True for a member-owned private record. An API key needs approved delegation to that owner; false alone does not bypass resource grants or other access rules."
        },
        "data": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "Name of the sales pipeline."
            },
            "stages": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "Stable stage ID referenced by deals. Keep it when changing the label."
                  },
                  "label": {
                    "type": "string",
                    "description": "Human-readable stage name."
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "open",
                      "won",
                      "lost"
                    ],
                    "description": "Whether this stage is open, won or lost."
                  },
                  "probability": {
                    "type": "number",
                    "description": "Integer percentage from 0 to 100 used for weighted sales value."
                  },
                  "tone": {
                    "type": "string",
                    "enum": [
                      "gray",
                      "blue",
                      "violet",
                      "peach",
                      "soon",
                      "accent",
                      "warn"
                    ],
                    "description": "Display color token for the stage."
                  }
                },
                "required": [
                  "id",
                  "label",
                  "kind"
                ],
                "additionalProperties": false
              },
              "description": "Sales stages in funnel order. Keep stage IDs stable: deals refer to them. Exactly one won and one lost stage appear last; probability is an integer percentage from 0 to 100 for weighted sales value."
            },
            "is_default": {
              "type": "boolean",
              "description": "Whether this is the workspace's default sales pipeline."
            }
          },
          "required": [
            "name"
          ],
          "additionalProperties": false,
          "description": "The record's fields.",
          "title": "SalesPipeline"
        }
      },
      "required": [
        "id",
        "created_at",
        "updated_at",
        "created_by",
        "private",
        "data"
      ],
      "additionalProperties": false,
      "description": "The requested record, including its metadata and data fields.",
      "title": "SalesPipelineRecord"
    },
    "created": {
      "type": "boolean",
      "description": "True when this external reference created a record; false when it matched an existing record."
    }
  },
  "required": [
    "item",
    "created"
  ],
  "additionalProperties": false,
  "examples": [
    {
      "item": {
        "id": "e_salespipeline_example",
        "created_at": 1791276900000,
        "updated_at": 1791280800000,
        "created_by": "a_jamie",
        "private": false,
        "data": {
          "name": "Sales pipeline",
          "is_default": true,
          "stages": [
            {
              "id": "lead",
              "label": "Lead",
              "kind": "open",
              "probability": 10
            },
            {
              "id": "won",
              "label": "Won",
              "kind": "won",
              "probability": 100
            },
            {
              "id": "lost",
              "label": "Lost",
              "kind": "lost",
              "probability": 0
            }
          ]
        }
      },
      "created": true
    }
  ]
}
```

