POST · Importer ou exporter

People : Importer ou exporter. Paramètres, accès et exemples de réponse.

Rédigé par Red Blue

Mis à jour le

People

POST /api/v1/people/transfers/commands

operationId : people_transfer

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

"import_upload"

kind, fileName, byteSize

request.type

"import_validate"

importId, settings

request.type

"import_change"

importId, action

request.type

"export_create"

kind

request.type

"export_cancel"

exportId

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/transfers/commands" \
  --header "Authorization: Bearer $KHONY_ACCESS_TOKEN" \
  --header 'X-Khony-Confirmation: 0198f886-9f71-7000-8000-000000000011' \
  --header 'Idempotency-Key: 0198f886-9f71-7000-8000-000000000010' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "productId": "product_01k3w8d7vhe008000000000001",
  "idempotencyKey": "0198f886-9f71-7000-8000-000000000010",
  "request": {
    "type": "export_create",
    "kind": "contacts"
  }
}'
Shell

Réponse de succès · HTTP 200

JSON
{
  "data": {
    "id": "export_job_01k3w8d7vhe008000000000003",
    "status": "pending"
  }
}
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": "import_upload"
            },
            "kind": {
              "$ref": "#/$defs/__schema0"
            },
            "fileName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "byteSize": {
              "type": "integer",
              "minimum": 1,
              "maximum": 52428800
            }
          },
          "required": [
            "type",
            "kind",
            "fileName",
            "byteSize"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "import_validate"
            },
            "importId": {
              "$ref": "#/$defs/__schema1"
            },
            "settings": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "format": {
                      "type": "string",
                      "const": "csv"
                    },
                    "mapping": {
                      "type": "object",
                      "propertyNames": {
                        "$ref": "#/$defs/__schema2"
                      },
                      "additionalProperties": {
                        "$ref": "#/$defs/__schema3"
                      }
                    },
                    "duplicatePolicy": {
                      "type": "string",
                      "enum": [
                        "skip",
                        "update"
                      ]
                    }
                  },
                  "required": [
                    "format",
                    "mapping",
                    "duplicatePolicy"
                  ],
                  "additionalProperties": false
                },
                {
                  "type": "object",
                  "properties": {
                    "format": {
                      "type": "string",
                      "const": "khony-json"
                    },
                    "mapping": {
                      "type": "object",
                      "properties": {},
                      "additionalProperties": false
                    },
                    "duplicatePolicy": {
                      "type": "string",
                      "enum": [
                        "skip",
                        "update"
                      ]
                    }
                  },
                  "required": [
                    "format",
                    "mapping",
                    "duplicatePolicy"
                  ],
                  "additionalProperties": false
                }
              ]
            }
          },
          "required": [
            "type",
            "importId",
            "settings"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "import_change"
            },
            "importId": {
              "$ref": "#/$defs/__schema1"
            },
            "action": {
              "type": "string",
              "enum": [
                "confirm",
                "cancel",
                "revert"
              ]
            }
          },
          "required": [
            "type",
            "importId",
            "action"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "export_create"
            },
            "kind": {
              "$ref": "#/$defs/__schema0"
            }
          },
          "required": [
            "type",
            "kind"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "export_cancel"
            },
            "exportId": {
              "type": "string",
              "pattern": "^export_job_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
            }
          },
          "required": [
            "type",
            "exportId"
          ],
          "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",
      "enum": [
        "contacts",
        "companies"
      ]
    },
    "__schema1": {
      "type": "string",
      "pattern": "^data_import_[0-7][0123456789abcdefghjkmnpqrstvwxyz]{25}$"
    },
    "__schema2": {
      "type": "string",
      "maxLength": 200
    },
    "__schema3": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    }
  }
}
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": "Current native administrator OAuth people:write and verified runtime human confirmation. Select import_upload/import_validate/import_change/export_create/export_cancel. Contacts/companies only. Upload returns a native size-bound signed CSV URL; upload the exact bytes before validation. Native validation produces a preview; confirm explicitly, or cancel/revert through native worker state transitions. Export is asynchronous and download requires a separate owned read. idempotencyKey binds runtime confirmation; this endpoint does not promise saved response replay. After uncertainty inspect native transfer history and state before retrying; signed URLs expire. Worker completion and remote storage are separate from command admission."
}
JSON