> ## Documentation Index
> Fetch the complete documentation index at: https://developer.vanta.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Set custom fields on vendors

> Attach organization-specific metadata — contract dates, internal owners, risk tiers, anything you track — to vendors when creating or updating them, using the Manage Vanta API.

This guide writes organization-specific metadata — contract dates, internal owners, risk tiers, ticket links — to vendors using `PATCH /v1/vendors/{vendorId}` with a `customFields` payload on the Manage Vanta API. Custom field labels must be defined in the Vanta vendor settings UI first; the API only fills in their values. The build prompt below generates a scheduled job that syncs a CSV export from a procurement or GRC system into Vanta, only PATCHing vendors whose fields actually changed.

Let AI do this for you

Copy the prompt to run this live via the [MCP server](https://developer.vanta.com/docs/vanta-mcp.md) or have AI generate a runnable script.

Code this

Generate a script or app that performs this function using the Vanta API.

You are writing a production-quality Node.js 18+ script that runs on a recurring schedule (cron / GitHub Actions / Cloud Scheduler) to keep vendor custom fields in Vanta in sync with a CSV exported from a procurement / GRC system. Use the Manage Vanta API (base URL [https://api.vanta.com](https://api.vanta.com)).

Steps:

1. Read VANTA\_CLIENT\_ID, VANTA\_CLIENT\_SECRET, and CSV\_PATH from env. Also accept STATE\_PATH (default ./.vanta-vendor-fields-state.json), DRY\_RUN (default "false"), and PICKLIST\_COLUMNS (comma-separated custom-field labels whose cells are semicolon-separated picklists; default empty). Fail fast on stderr if any required var is missing.
2. Mint a Vanta API token via POST [https://api.vanta.com/oauth/token](https://api.vanta.com/oauth/token) with Content-Type: application/json and a JSON body containing client\_id, client\_secret, grant\_type="client\_credentials", and scope="vanta-api.all:read vanta-api.all:write". The scope field is required — omitting it returns invalid\_scope. Read access\_token from the response. Re-mint at the start of each run (tokens expire after one hour).
3. Parse CSV\_PATH using a lightweight built-in parser that handles quoted fields and commas inside quotes. The first column must be websiteUrl; every other column header is the literal label of a custom field already defined in Vanta vendor settings.
4. Page through GET [https://api.vanta.com/v1/vendors?pageSize=100](https://api.vanta.com/v1/vendors?pageSize=100) using the pageCursor request param (read results.pageInfo.endCursor and hasNextPage until hasNextPage is false). Build a Map keyed by websiteUrl normalized to lowercase + trimmed. Each value is the full vendor object.
5. For each CSV row, look up the vendor by normalized websiteUrl. Classify as missing-vendor when no match. For each non-websiteUrl column, coerce the CSV cell to the field's expected JSON shape: empty cell -> empty string "" (clears the field); a cell in a picklist column -> JSON array of strings, split on semicolons and trimmed; everything else -> the cell verbatim as a string, even for numeric- or boolean-looking values (the API rejects literal JSON numbers/booleans in customFields.value with a 400). Do not infer picklists from punctuation: a scalar text field can legitimately contain a semicolon (for example "SOC 2; ISO 27001"), and splitting it would send the wrong shape. Read the picklist column labels from PICKLIST\_COLUMNS (comma-separated, default empty) and split only those.
6. Diff each row's coerced values against the vendor's existing customFields\[] (label match is exact, case-sensitive). Build a `changes` array of \{ label, value } only for entries that differ from the current value. If `changes` is empty, classify the row as skipped.
7. Load STATE\_PATH if present — \{ "lastSyncedHash": \{ "\<vendorId>": "\<sha-of-changes>" } } — and skip rows whose computed hash already matches (idempotent re-runs).
8. Print the plan: vendorId | name | websiteUrl | fieldsToUpdate (count) | classification (updated / skipped / missing-vendor).
9. If DRY\_RUN === "true", print a JSON summary and exit 0 without writing.
10. For each row classified as updated, PATCH [https://api.vanta.com/v1/vendors/\\\{vendorId\\}](https://api.vanta.com/v1/vendors/\\\{vendorId\\}) with body \{ "customFields": \<changes> }. Send only the changed fields — omitted labels keep their current value. Issue requests sequentially to keep ordering deterministic and stay under rate limits.
11. After every successful PATCH, record state.lastSyncedHash\[vendorId] = sha of changes; write STATE\_PATH atomically (temp file + rename). Log id, name, websiteUrl, updatedFields\[], status (SUCCESS / ERROR), and any error message.
12. End with a single JSON summary line on stdout: \{"total": N, "updated": U, "skipped": S, "missingVendors": M, "errors": E}.

Sample API response item from GET /v1/vendors (use these field names exactly):
\{ "id": "a2f7e1b9d0c3f4e5a6c7b8d8", "name": "Vanta", "websiteUrl": "[https://www.vanta.com/](https://www.vanta.com/)", "category": \{ "displayName": "cloudMonitoring" }, "inherentRiskLevel": "HIGH", "residualRiskLevel": "MEDIUM", "contractStartDate": "2024-02-01T00:00:00.000Z", "contractRenewalDate": "2025-02-01T00:00:00.000Z", "customFields": \[\{ "label": "contractEndDate", "value": "2026-01-01T00:00:00.000Z" }, \{ "label": "internalRiskTier", "value": "Tier 2" }] }

Sample API response from PATCH /v1/vendors/\{vendorId}: the full vendor object with the updated customFields\[] populated.

Missing-field handling: if customFields is null on the vendor, treat as \[]. If a CSV column header doesn't match any defined custom field in Vanta, the API will return 400 — log that label and skip the row. Never throw on a missing optional field.

Error handling:

* 401: re-mint once and retry the request.
* 400 saying the custom field doesn't exist: log the label, mark the row as ERROR, continue. Field labels must be defined in the Vanta UI — the API only fills them.
* 400 saying the value type is wrong: log the field, expected vs actual type, and the offending value; mark ERROR and continue.
* 404 on PATCH: vendor was deleted between the list and patch. Log and continue.
* 429: respect Retry-After header if present, otherwise sleep 5s; retry up to 3 times.
* 5xx: retry with 2s exponential back-off, max 3 attempts; then log and exit non-zero only if every PATCH failed.

Do not:

* Add external dependencies — use built-in fetch, fs, path, and crypto only. The CSV parser is a small built-in helper, not an npm package.
* Hard-code any vendor id, websiteUrl, custom field label, or value — every customer's vendor list and field schema is different. Always read CSV\_PATH and discover vendors via /v1/vendors.
* Send `category` in the same PATCH as `customFields` — combining them wipes category-derived risk attributes before applying custom values. customFields-only PATCH is safe.
* Apply changes when DRY\_RUN is "true".
* Cache the access token across runs.
* Silently swallow errors.

Done when: a follow-up run with an unchanged CSV reports 0 updates (idempotent). Exit 0 if errors === 0; otherwise exit 1.

Scope required: vanta-api.all:read vanta-api.all:write.

Copy prompt

[Cursor](#)
[Claude](#)
[ChatGPT](#)

## Before you begin

This guide is for Vanta admins managing data inside their own Vanta account.

You'll need:

* A Manage Vanta [API token](https://developer.vanta.com/docs/quickstart/manage-vanta.md).
* The token must have scopes `vanta-api.all:read` and `vanta-api.all:write`.
* The custom fields you want to set must be defined ahead of time in the Vanta UI (the API can only **fill** custom fields, not create them).

Custom fields let you attach organization-specific metadata to vendors — contract end dates, internal owners, risk ratings, or anything else you track. They're defined in the [Vendor settings page](https://app.vanta.com/vendors) by name and type, then set or updated via the API.

> [!NOTE]
>
> Custom fields are also supported on **risk scenarios**. See [Create and update risk scenarios](https://developer.vanta.com/docs/guides/create-risk-scenarios.md) for that flow. Each object type has its own settings page where you define the field labels, and the API only fills existing definitions on that object type. Labels defined for vendors are not visible to risk scenarios, and vice versa.

> [!NOTE]
>
> Importing a backlog of vendors from your procurement system? Define every custom field you'll send first in the [Vendor settings page](https://app.vanta.com/vendors), then run Step 1 in a loop. Field names sent in the API must match the Vanta-side `label` exactly — including case. Regardless of how the field is typed in the UI, `customFields[].value` is always a **JSON string** (or an array of strings for picklists) — never a literal JSON number or boolean:
>
> * **Text / number / date / currency** — JSON string: `"value": "Tier 1"`, `"value": "10"`, `"value": "2026-01-01T00:00:00.000Z"`
> * **Boolean** — string, not a bool: `"value": "true"` (sending `"value": true` returns a 400)
> * **Picklist** — JSON array of strings: `"value": ["Tier 1", "Tier 2"]`

**1. Set custom fields when creating a vendor**

**Your terminal** — `POST /v1/vendors` with a `customFields` array. Each entry has `label` (matches the Vanta-side field name) and `value` (matches the field's type).

```javascript Node.js theme={"system"}
const res = await fetch("https://api.vanta.com/v1/vendors", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    name: "Acme Corp",
    websiteUrl: "https://acmecorp.com",
    category: "cloudStorage",
    customFields: [
      { label: "contractEndDate", value: "2026-01-01T00:00:00.000Z" },
      { label: "internalRiskTier", value: "Tier 2" },
    ],
  }),
});
const vendor = await res.json();
console.log(vendor.id);
```

```python Python theme={"system"}
import requests

r = requests.post(
    "https://api.vanta.com/v1/vendors",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    json={
        "name": "Acme Corp",
        "websiteUrl": "https://acmecorp.com",
        "category": "cloudStorage",
        "customFields": [
            {"label": "contractEndDate", "value": "2026-01-01T00:00:00.000Z"},
            {"label": "internalRiskTier", "value": "Tier 2"},
        ],
    },
)
r.raise_for_status()
print(r.json()["id"])
```

```bash Terminal theme={"system"}
curl -X POST 'https://api.vanta.com/v1/vendors' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{
    "name": "Acme Corp",
    "websiteUrl": "https://acmecorp.com",
    "category": "cloudStorage",
    "customFields": [
      { "label": "contractEndDate", "value": "2026-01-01T00:00:00.000Z" },
      { "label": "internalRiskTier", "value": "Tier 2" }
    ]
  }'
```

Expected response (`200`) — the full vendor object, including the values you just set:

```json theme={"system"}
{
  "id": "a2f7e1b9d0c3f4e5a6c7b8d8",
  "name": "Acme Corp",
  "category": { "displayName": "cloudStorage" },
  "customFields": [
    { "label": "contractEndDate", "value": "2026-01-01T00:00:00.000Z" },
    { "label": "internalRiskTier", "value": "Tier 2" }
  ]
}
```

> [accordion] Got a 400 saying the custom field doesn't exist?
>
> The `label` doesn't match a defined custom field. Check the [Vendor settings page](https://app.vanta.com/vendors) — labels are case-sensitive and must match exactly.

> [accordion] Got a 400 saying the value type is wrong?
>
> Your value doesn't match the custom field's type. `value` is always a JSON string, or an array of strings for a picklist — never a literal JSON number or boolean. A `Date` field needs an ISO 8601 string; a `Number` field needs `"42"`, not `42`; a `Boolean` field needs `"true"`, not `true`.

**2. Update custom fields on an existing vendor**

**Your terminal** — `PATCH /v1/vendors/{vendorId}` with the same `customFields` shape. Only the fields you send are changed; omitted fields keep their current values.

```javascript Node.js theme={"system"}
const VENDOR_ID = "YOUR_VENDOR_ID";

const res = await fetch(`https://api.vanta.com/v1/vendors/${VENDOR_ID}`, {
  method: "PATCH",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify({
    customFields: [
      { label: "contractEndDate", value: "2027-01-01T00:00:00.000Z" },
    ],
  }),
});
console.log(await res.json());
```

```python Python theme={"system"}
import requests

VENDOR_ID = "YOUR_VENDOR_ID"

r = requests.patch(
    f"https://api.vanta.com/v1/vendors/{VENDOR_ID}",
    headers={"Authorization": "Bearer YOUR_TOKEN"},
    json={
        "customFields": [
            {"label": "contractEndDate", "value": "2027-01-01T00:00:00.000Z"},
        ]
    },
)
r.raise_for_status()
print(r.json())
```

```bash Terminal theme={"system"}
VENDOR_ID="YOUR_VENDOR_ID"

curl -X PATCH "https://api.vanta.com/v1/vendors/$VENDOR_ID" \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{
    "customFields": [
      { "label": "contractEndDate", "value": "2027-01-01T00:00:00.000Z" }
    ]
  }'
```

A `200` response returns the updated vendor with its new `customFields`.

> [!WARNING]
>
> Sending `customFields` with `category` in the same call wipes any category-derived risk attributes before applying your custom values — see the [Create a vendor guide](https://developer.vanta.com/docs/guides/create-vendors-and-attach-documentation.md) for the ordering rules.

> [accordion] Got a 404?
>
> The `vendorId` is wrong. Re-run [`GET /v1/vendors`](https://developer.vanta.com/reference/manage-vanta/overview) and copy the `id` exactly, or grab it from the URL on the [Vendor page](https://app.vanta.com/vendors).

> [accordion] Need to clear a custom field?
>
> Send the field with `value: ""` (text/number/date/currency/boolean) or `value: []` (picklist). `customFields[].value` doesn't accept `null` — the label still has to match a defined field.

> [!NOTE]
>
> **Bulk-syncing from a procurement system?** List vendors with `GET /v1/vendors`, match each one to your source-of-truth record by `name` or `websiteUrl`, then run Step 2 per vendor with the latest custom-field values. Tokens expire hourly — re-mint at the top of each run.

## Congratulations

You've populated organization-specific metadata on your vendors. Custom field values are visible on each vendor's profile, queryable via the API, and included in vendor exports for auditors.

## Next steps

> [card] [Create a vendor and attach evidence](https://developer.vanta.com/docs/guides/create-vendors-and-attach-documentation.md)
>
> Set up a new vendor end-to-end with metadata, custom fields, and a SOC 2 report.

> [card] [Assign a control owner](https://developer.vanta.com/docs/guides/add-an-owner-to-a-control.md)
>
> Make a specific user accountable for vendor-management controls.

> [card] [Try it in Postman](https://developer.vanta.com/docs/postman-setup.md)
>
> Import the collection and run vendor `POST` and `PATCH` against a sandbox in seconds.

> [card] [Manage Vanta API reference](https://developer.vanta.com/reference/manage-vanta/overview.md)
>
> Browse every Manage Vanta endpoint — vendors, controls, tests, documents, people.


## Related topics

- [Create and update risk scenarios](https://developer.vanta.com/docs/guides/create-risk-scenarios.md)
- [List vendor custom field definitions](https://developer.vanta.com/api-reference/vendor-custom-fields/list-vendor-custom-field-definitions.md)
- [Set vendor status](https://developer.vanta.com/api-reference/vendors/set-vendor-status.md)
- [Create a vendor](https://developer.vanta.com/api-reference/vendors/create-a-vendor.md)
- [Update vendor by ID](https://developer.vanta.com/api-reference/vendors/update-vendor-by-id.md)
