{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/popp/json-schema/popp-create-candidate-request-schema.json",
  "title": "CreateCandidateRequest",
  "description": "Payload for creating (or upserting) a candidate profile. The organization group is always taken from the authenticated API key and can never be set from the body. The organization within that group defaults to the API key's own, and may be chosen with externalOrganizationId, which is authorised against the access of the user the key belongs to.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/popp-candidates-api-openapi.yml#/components/schemas/CreateCandidateRequest",
  "type": "object",
  "properties": {
    "mode": {
      "type": "string",
      "enum": [
        "SYNC",
        "ASYNC"
      ],
      "title": "Processing Mode",
      "description": "Controls how much of the work the request waits for — specifically whether the document is downloaded before responding. SYNC creates/upserts the profile and downloads the document (when documentUrl is supplied) during the request, returning 201 when newly created or 200 when an existing profile was upserted; a failed download surfaces as a 502. ASYNC queues the work and returns 202 immediately with the resolved id, downloading the document in the background. CV parsing and vectorization are always asynchronous in both modes. documentBase64 is not supported in ASYNC mode."
    },
    "externalId": {
      "type": "string",
      "title": "External ID",
      "description": "Caller-supplied identifier (typically matching ^[\\w.-]+$). Drives the deterministic candidate profile id and de-duplication; re-posting the same externalId upserts the existing profile. Leading and trailing whitespace is trimmed before the id is derived, so \" abc \" and \"abc\" address the same candidate; a value that is empty once trimmed is rejected.",
      "minLength": 1
    },
    "externalOrganizationId": {
      "type": "string",
      "title": "External Organization ID",
      "description": "Your own identifier for the organization this candidate belongs to, used instead of relying on the organization the API key defaults to. Resolved to a Popp organization within your organization group and checked against the access of the user the API key belongs to. For a new candidate it sets the organization the candidate is created in, instead of the organization the API key defaults to. For a candidate that already exists it is additive: the named organization is added to the ones the candidate already has, and none are removed. A candidate cannot be moved between organizations, because its vector-DB tenant follows the organizations it belongs to and a vector cannot be withdrawn from a tenant it has already been indexed into. Unknown or ambiguous values are rejected with a 400, and an organization the user cannot reach with a 403. Leading and trailing whitespace is trimmed before it is matched; a value that is empty once trimmed is rejected.",
      "minLength": 1
    },
    "firstName": {
      "type": "string",
      "description": "Candidate's first name."
    },
    "lastName": {
      "type": "string",
      "description": "Candidate's last name."
    },
    "email": {
      "type": "string",
      "format": "email",
      "description": "Candidate's email address."
    },
    "phoneNumber": {
      "type": "string",
      "description": "Candidate's phone number."
    },
    "linkedInProfileUrl": {
      "type": "string",
      "description": "URL of the candidate's LinkedIn profile."
    },
    "title": {
      "type": "string",
      "description": "Candidate's current job title."
    },
    "company": {
      "type": "string",
      "description": "Candidate's current company."
    },
    "externalUrl": {
      "type": "string",
      "description": "The caller's link back to this candidate in their own system. This is not the candidate's own profile page — use linkedInProfileUrl for that."
    },
    "customFields": {
      "type": "object",
      "description": "Values for the custom fields your organization has defined, keyed by fieldKey. Each key must name a live custom field, and each value must match the type configured for it, or the request is rejected. Manage the definitions through the custom-fields endpoints. In SYNC mode an unknown key or a mistyped value is rejected here; in ASYNC mode the request is accepted and the same problem is reported on the candidate processing webhook, except that a null for an unknown key is ignored rather than reported.",
      "additionalProperties": {
        "description": "Value for one custom field. The accepted shape follows the type the organization configured for that field: string for TEXT, array of strings for TEXT_ARRAY, number for NUMBER, boolean for BOOLEAN, and a date string for DATE. Null is accepted and stores nothing; on an existing candidate it clears the key.",
        "anyOf": [
          {
            "type": [
              "string",
              "null"
            ]
          },
          {
            "type": [
              "number",
              "null"
            ]
          },
          {
            "type": [
              "boolean",
              "null"
            ]
          },
          {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          }
        ]
      }
    },
    "location": {
      "type": [
        "object",
        "null"
      ],
      "description": "Candidate's location. The object replaces the stored location wholesale; null clears it. Coordinates are derived by Popp during processing and are not accepted here. When name is omitted it is composed from the other parts. At least one of name, city, region or countryCode must carry a value: an object with none of them, or only blank ones, is rejected — send null to clear the stored location.",
      "minProperties": 1,
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "description": "Free-text location name, for example \"London, UK\"."
        },
        "city": {
          "type": "string",
          "description": "City, for example \"London\"."
        },
        "region": {
          "type": "string",
          "description": "Region, state or county, for example \"England\"."
        },
        "countryCode": {
          "type": "string",
          "pattern": "^[A-Za-z]{2}$",
          "description": "ISO 3166-1 alpha-2 country code, for example \"GB\". Normalised to upper case."
        }
      }
    },
    "skills": {
      "type": "object",
      "description": "Candidate skills, with how they combine with values extracted from the CV during processing.",
      "properties": {
        "data": {
          "type": "array",
          "description": "The caller-supplied values.",
          "items": {
            "type": "string"
          }
        },
        "mode": {
          "type": "string",
          "enum": [
            "MERGE",
            "OVERWRITE"
          ],
          "description": "How the supplied values combine with CV-extracted ones. Defaults to MERGE."
        }
      },
      "required": [
        "data"
      ],
      "additionalProperties": false
    },
    "qualifications": {
      "type": "object",
      "description": "Candidate qualifications, with how they combine with values extracted from the CV during processing.",
      "properties": {
        "data": {
          "type": "array",
          "description": "The caller-supplied values.",
          "items": {
            "type": "string"
          }
        },
        "mode": {
          "type": "string",
          "enum": [
            "MERGE",
            "OVERWRITE"
          ],
          "description": "How the supplied values combine with CV-extracted ones. Defaults to MERGE."
        }
      },
      "required": [
        "data"
      ],
      "additionalProperties": false
    },
    "tags": {
      "type": "array",
      "description": "Candidate tags. These always replace the stored tags — nothing derives tags from a CV, so there is no combine mode. Note that a subsequent ATS sync replaces tags wholesale, so tags set here do not survive one.",
      "items": {
        "type": "string"
      }
    },
    "documentUrl": {
      "type": "string",
      "description": "URL of a CV/document to fetch (using the organization group's stored document credential) and store against the candidate."
    },
    "documentBase64": {
      "type": "string",
      "description": "Inline CV/document as a data URI or raw base64. Takes precedence over documentUrl when both are given. SYNC mode only — an inline document can exceed the async queue's message size. Must be valid base64 (optionally as a data URI); a value that is not is rejected rather than stored as an unreadable document."
    },
    "priority": {
      "type": "integer",
      "minimum": 0,
      "maximum": 2,
      "description": "Priority band for processing: 0 (most urgent), 1 or 2."
    },
    "sourceTime": {
      "type": "string",
      "format": "date-time",
      "description": "The change time that orders a priority band (ISO 8601), so processing across the organization group stays correctly ordered."
    }
  },
  "required": [
    "mode"
  ],
  "additionalProperties": false
}