POST · Modifier

People : Modifier. Paramètres, accès et exemples de réponse.

Rédigé par Red Blue

Mis à jour le

People

POST /api/v1/people/commands

operationId : people_command

Accès

Permission

Consentements OAuth

OAuth : délégation d’un équipier pour l’API

product.update

api:connect, people:write

KHONY_ORIGIN est l’origine HTTPS de votre application Khony, sans chemin final. Remplacez les identifiants de l’exemple par ceux de vos ressources autorisées. Les données de réponse ci-dessous illustrent le format ; elles ne sont pas le résultat d’un appel à votre organisation.

Champs du corps JSON

Nom

Emplacement

Requis

Type et contraintes

productId

JSON

Oui

string

request

JSON

Oui

object

idempotencyKey

JSON

Oui

string ; uuid

Variantes de la requête

Sélecteur

Valeur

Autres champs requis dans request

request.type

"add_contacts"

emails

request.type

"create_company"

name

request.type

"profile"

contactId, expectedRevision, property, value

request.type

"qualification"

contactId, fieldId, expectedRevision, value

request.type

"tag"

contactId, tagId, assigned

request.type

"create_tag"

name, color

request.type

"relationship"

contactId, kind, assigned

request.type

"create_field"

name, target, dataType

request.type

"create_segment"

name, target, attributeKey, operator

request.type

"qualification_field"

fieldId, expectedRevision, enabled

Choisissez une variante et respectez son schéma complet : les contraintes des champs optionnels et les unions imbriquées restent applicables.

Exemple de requête

Shell
curl --request POST "$KHONY_ORIGIN/api/v1/people/commands" \
  --header "Authorization: Bearer $KHONY_ACCESS_TOKEN" \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "productId": "product_01k3w8d7vhe008000000000001",
  "idempotencyKey": "0198f886-9f71-7000-8000-000000000010",
  "request": {
    "type": "profile",
    "contactId": "contact_01k3w8d7vhe008000000000002",
    "expectedRevision": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "property": "name",
    "value": "Ada Moreau"
  }
}'
Shell

Réponse de succès · HTTP 200

JSON
{
  "data": {
    "id": "contact_01k3w8d7vhe008000000000002",
    "revision": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
  }
}
JSON
Schéma complet du corps JSON
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "productId": {
      "type": "string",
      "pattern": "^product_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
    },
    "request": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "add_contacts"
            },
            "emails": {
              "minItems": 1,
              "maxItems": 50,
              "type": "array",
              "items": {
                "$ref": "#/$defs/__schema0"
              }
            }
          },
          "required": [
            "type",
            "emails"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "create_company"
            },
            "name": {
              "type": "string",
              "minLength": 2,
              "maxLength": 120
            },
            "domain": {
              "type": "string",
              "maxLength": 253,
              "pattern": "^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$"
            }
          },
          "required": [
            "type",
            "name"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "profile"
            },
            "contactId": {
              "$ref": "#/$defs/__schema1"
            },
            "expectedRevision": {
              "$ref": "#/$defs/__schema2"
            },
            "property": {
              "type": "string",
              "enum": [
                "name",
                "email",
                "externalId",
                "preferredLocale",
                "attribute"
              ]
            },
            "key": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "value": {
              "$ref": "#/$defs/__schema3"
            }
          },
          "required": [
            "type",
            "contactId",
            "expectedRevision",
            "property",
            "value"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "qualification"
            },
            "contactId": {
              "$ref": "#/$defs/__schema1"
            },
            "companyId": {
              "type": "string",
              "pattern": "^company_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
            },
            "fieldId": {
              "type": "string",
              "pattern": "^custom_field_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
            },
            "expectedRevision": {
              "$ref": "#/$defs/__schema2"
            },
            "value": {
              "$ref": "#/$defs/__schema3"
            }
          },
          "required": [
            "type",
            "contactId",
            "fieldId",
            "expectedRevision",
            "value"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "tag"
            },
            "contactId": {
              "$ref": "#/$defs/__schema1"
            },
            "tagId": {
              "type": "string",
              "pattern": "^person_tag_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
            },
            "assigned": {
              "type": "boolean"
            }
          },
          "required": [
            "type",
            "contactId",
            "tagId",
            "assigned"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "create_tag"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 50
            },
            "color": {
              "type": "string",
              "enum": [
                "gray",
                "red",
                "amber",
                "green",
                "blue",
                "violet",
                "pink"
              ]
            }
          },
          "required": [
            "type",
            "name",
            "color"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "$ref": "#/$defs/__schema4"
            },
            "contactId": {
              "$ref": "#/$defs/__schema1"
            },
            "kind": {
              "$ref": "#/$defs/__schema5"
            },
            "recordId": {
              "$ref": "#/$defs/__schema6"
            },
            "name": {
              "$ref": "#/$defs/__schema7"
            },
            "assigned": {
              "$ref": "#/$defs/__schema8"
            }
          },
          "required": [
            "type",
            "contactId",
            "kind",
            "assigned"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "create_field"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "target": {
              "type": "string",
              "enum": [
                "contact",
                "company"
              ]
            },
            "dataType": {
              "type": "string",
              "enum": [
                "text",
                "number",
                "select",
                "date",
                "boolean"
              ]
            },
            "options": {
              "default": [],
              "maxItems": 100,
              "type": "array",
              "items": {
                "$ref": "#/$defs/__schema9"
              }
            },
            "required": {
              "default": false,
              "type": "boolean"
            }
          },
          "required": [
            "type",
            "name",
            "target",
            "dataType"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "create_segment"
            },
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "target": {
              "type": "string",
              "enum": [
                "contact",
                "company"
              ]
            },
            "attributeKey": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "operator": {
              "type": "string",
              "enum": [
                "equals",
                "not_equals",
                "contains",
                "exists"
              ]
            },
            "comparisonValue": {
              "type": "string",
              "maxLength": 500
            }
          },
          "required": [
            "type",
            "name",
            "target",
            "attributeKey",
            "operator"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "qualification_field"
            },
            "fieldId": {
              "type": "string",
              "pattern": "^custom_field_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
            },
            "expectedRevision": {
              "$ref": "#/$defs/__schema2"
            },
            "enabled": {
              "type": "boolean"
            }
          },
          "required": [
            "type",
            "fieldId",
            "expectedRevision",
            "enabled"
          ],
          "additionalProperties": false
        }
      ]
    },
    "idempotencyKey": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    }
  },
  "required": [
    "productId",
    "request",
    "idempotencyKey"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "type": "string",
      "maxLength": 320,
      "format": "email",
      "pattern": "^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$"
    },
    "__schema1": {
      "type": "string",
      "pattern": "^contact_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
    },
    "__schema2": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "__schema3": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 500
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ]
    },
    "__schema4": {
      "type": "string",
      "const": "relationship"
    },
    "__schema5": {
      "type": "string",
      "enum": [
        "companies",
        "segments"
      ]
    },
    "__schema6": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "__schema7": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50
    },
    "__schema8": {
      "type": "boolean"
    },
    "__schema9": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    }
  }
}
JSON
Schéma complet de la réponse
JSON
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "$ref": "#/$defs/__schema0"
    }
  },
  "required": [
    "data"
  ],
  "additionalProperties": false,
  "$defs": {
    "__schema0": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/__schema0"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "$ref": "#/$defs/__schema0"
          }
        }
      ]
    }
  }
}
JSON

Refus et reprise

Les statuts documentés pour cette opération sont 400, 401, 402, 403, 404, 409, 428, 429, 500, 503. Identifiez la cause avec error.code et, lorsqu’il est présent, error.reason. Une réponse 409 peut demander une relecture de révision ou signaler une commande incompatible ; une réponse 428 demande une confirmation humaine. Ne rejouez une écriture que selon son contrat.

Notes du contrat
JSON
{
  "description": "Dedicated API OAuth api:connect + people:write and a current native product administrator. Select add_contacts/create_company/profile/qualification/tag/create_tag/relationship/create_field/create_segment/qualification_field. idempotencyKey is a stable UUID bound to actor, transport and exact request; replay returns the saved result, different input conflicts. Profile/qualification/field writes require the inspected expectedRevision. Relationships and tags use desired assigned state; computed segments refuse manual assignment. Native validation, transactions and outbox effects apply. Contact creation here never sends email; use invitations explicitly. Billing write lock and request admission apply."
}
JSON