Методы API
DEVELOPER PLATFORM · v1

API, с которым удобно работать

CRM, кампании, аналитика и интеграции. Точные контракты, понятные примеры и подписанные вебхуки.

Скачать OpenAPI

Private preview: API доступен с проектным ключом. Публичные SLA и сроки поддержки ещё не установлены.

PATCH

Изменить сделку CRM

/api/v1/developer/crm/deals/{dealId}

Изменяет core-поля, tags, stage, lifecycle или состав позиций сделки одной идемпотентной командой. CRM фиксирует текущую цену товара и пересчитывает бюджет.

Право доступаcrm.deals.write

Authorization: Bearer YOUR_PROJECT_TOKEN

Параметры

dealIdобязательно · path

stringminLength: 1 · maxLength: 160

JSON Schema
{
  "type": "string",
  "minLength": 1,
  "maxLength": 160
}
idempotency-keyобязательно · header

stringpattern: "^[A-Za-z0-9][A-Za-z0-9._:-]{7,159}$"

JSON Schema
{
  "type": "string",
  "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{7,159}$"
}

Тело запроса

application/json

union

Вариант 1

object

operationобязательно
stringenum: ["core"]
title
stringminLength: 1 · maxLength: 240
budgetMinor
integerminimum: 0 · maximum: 9000000000000
expectedCloseDate
string | nullformat: "date"
responsibleIdentityId
stringminLength: 1 · maxLength: 160
organizationId
string | nullminLength: 1 · maxLength: 160
JSON Schema
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "enum": [
        "core"
      ]
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 240
    },
    "budgetMinor": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9000000000000
    },
    "expectedCloseDate": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "responsibleIdentityId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "organizationId": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 160
    }
  },
  "required": [
    "operation"
  ],
  "additionalProperties": false
}
Вариант 2

object

operationобязательно
stringenum: ["tags"]
tagsобязательно
arraymaxItems: 50
Вложенная схема

arraymaxItems: 50

stringminLength: 1 · maxLength: 80

JSON Schema
{
  "type": "string",
  "minLength": 1,
  "maxLength": 80
}
JSON Schema
{
  "type": "array",
  "items": {
    "type": "string",
    "minLength": 1,
    "maxLength": 80
  },
  "maxItems": 50
}
JSON Schema
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "enum": [
        "tags"
      ]
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 80
      },
      "maxItems": 50
    }
  },
  "required": [
    "operation",
    "tags"
  ],
  "additionalProperties": false
}
Вариант 3

object

operationобязательно
stringenum: ["stage"]
stageIdобязательно
stringminLength: 1 · maxLength: 160
lossReasonId
stringminLength: 1 · maxLength: 160
JSON Schema
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "enum": [
        "stage"
      ]
    },
    "stageId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "lossReasonId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    }
  },
  "required": [
    "operation",
    "stageId"
  ],
  "additionalProperties": false
}
Вариант 4

object

operationобязательно
stringenum: ["lifecycle"]
lifecycleобязательно
stringenum: ["active","archived"]
JSON Schema
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "enum": [
        "lifecycle"
      ]
    },
    "lifecycle": {
      "type": "string",
      "enum": [
        "active",
        "archived"
      ]
    }
  },
  "required": [
    "operation",
    "lifecycle"
  ],
  "additionalProperties": false
}
Вариант 5

object

operationобязательно
stringenum: ["line_item_attach"]
productIdобязательно
stringminLength: 1 · maxLength: 160
quantity
integerminimum: 1 · maximum: 10000 · default: 1
JSON Schema
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "enum": [
        "line_item_attach"
      ]
    },
    "productId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "quantity": {
      "type": "integer",
      "minimum": 1,
      "maximum": 10000,
      "default": 1
    }
  },
  "required": [
    "operation",
    "productId"
  ],
  "additionalProperties": false
}
Вариант 6

object

operationобязательно
stringenum: ["line_item_remove"]
dealProductIdобязательно
stringminLength: 1 · maxLength: 160
JSON Schema
{
  "type": "object",
  "properties": {
    "operation": {
      "type": "string",
      "enum": [
        "line_item_remove"
      ]
    },
    "dealProductId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    }
  },
  "required": [
    "operation",
    "dealProductId"
  ],
  "additionalProperties": false
}
JSON Schema
{
  "oneOf": [
    {
      "type": "object",
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "core"
          ]
        },
        "title": {
          "type": "string",
          "minLength": 1,
          "maxLength": 240
        },
        "budgetMinor": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9000000000000
        },
        "expectedCloseDate": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "responsibleIdentityId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "organizationId": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 160
        }
      },
      "required": [
        "operation"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "tags"
          ]
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "maxItems": 50
        }
      },
      "required": [
        "operation",
        "tags"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "stage"
          ]
        },
        "stageId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "lossReasonId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        }
      },
      "required": [
        "operation",
        "stageId"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "lifecycle"
          ]
        },
        "lifecycle": {
          "type": "string",
          "enum": [
            "active",
            "archived"
          ]
        }
      },
      "required": [
        "operation",
        "lifecycle"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "line_item_attach"
          ]
        },
        "productId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        "quantity": {
          "type": "integer",
          "minimum": 1,
          "maximum": 10000,
          "default": 1
        }
      },
      "required": [
        "operation",
        "productId"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "operation": {
          "type": "string",
          "enum": [
            "line_item_remove"
          ]
        },
        "dealProductId": {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        }
      },
      "required": [
        "operation",
        "dealProductId"
      ],
      "additionalProperties": false
    }
  ],
  "$ref": "#/components/schemas/UpdateDeveloperCrmDealRequest"
}

Примеры запроса

curl --request PATCH   'https://YOUR_NOVA_HOST/api/v1/developer/crm/deals/DEAL_ID'   --header 'Authorization: Bearer YOUR_PROJECT_TOKEN'   --header 'Idempotency-Key: YOUR_UNIQUE_COMMAND_ID'   --header 'Content-Type: application/json'   --data '{"operation":"tags","tags":["priority"]}'

Ответы

200 Updated CRM deal receipt
application/json

object

resourceIdобязательно
stringminLength: 1 · maxLength: 160
changedобязательно
boolean
JSON Schema
{
  "type": "object",
  "properties": {
    "resourceId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "changed": {
      "type": "boolean"
    }
  },
  "required": [
    "resourceId",
    "changed"
  ],
  "$ref": "#/components/schemas/DeveloperMutationResponse"
}
400 Invalid deal command or idempotency key
application/problem+json

object

type
stringformat: "uri" · default: "about:blank"
titleобязательно
string
statusобязательно
integerminimum: 100 · maximum: 599
detail
string
instance
string
errors
object
JSON Schema
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "format": "uri",
      "default": "about:blank"
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer",
      "minimum": 100,
      "maximum": 599
    },
    "detail": {
      "type": "string"
    },
    "instance": {
      "type": "string"
    },
    "errors": {
      "type": "object",
      "additionalProperties": {}
    }
  },
  "required": [
    "title",
    "status"
  ]
}
401 Invalid developer credential
application/problem+json

object

type
stringformat: "uri" · default: "about:blank"
titleобязательно
string
statusобязательно
integerminimum: 100 · maximum: 599
detail
string
instance
string
errors
object
JSON Schema
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "format": "uri",
      "default": "about:blank"
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer",
      "minimum": 100,
      "maximum": 599
    },
    "detail": {
      "type": "string"
    },
    "instance": {
      "type": "string"
    },
    "errors": {
      "type": "object",
      "additionalProperties": {}
    }
  },
  "required": [
    "title",
    "status"
  ]
}
404 CRM deal reference not found
application/problem+json

object

type
stringformat: "uri" · default: "about:blank"
titleобязательно
string
statusобязательно
integerminimum: 100 · maximum: 599
detail
string
instance
string
errors
object
JSON Schema
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "format": "uri",
      "default": "about:blank"
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer",
      "minimum": 100,
      "maximum": 599
    },
    "detail": {
      "type": "string"
    },
    "instance": {
      "type": "string"
    },
    "errors": {
      "type": "object",
      "additionalProperties": {}
    }
  },
  "required": [
    "title",
    "status"
  ]
}
409 Idempotency key conflict
application/problem+json

object

type
stringformat: "uri" · default: "about:blank"
titleобязательно
string
statusобязательно
integerminimum: 100 · maximum: 599
detail
string
instance
string
errors
object
JSON Schema
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "format": "uri",
      "default": "about:blank"
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer",
      "minimum": 100,
      "maximum": 599
    },
    "detail": {
      "type": "string"
    },
    "instance": {
      "type": "string"
    },
    "errors": {
      "type": "object",
      "additionalProperties": {}
    }
  },
  "required": [
    "title",
    "status"
  ]
}
429 Developer API rate limit exceeded
application/problem+json

object

type
stringformat: "uri" · default: "about:blank"
titleобязательно
string
statusобязательно
integerminimum: 100 · maximum: 599
detail
string
instance
string
errors
object
JSON Schema
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "format": "uri",
      "default": "about:blank"
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer",
      "minimum": 100,
      "maximum": 599
    },
    "detail": {
      "type": "string"
    },
    "instance": {
      "type": "string"
    },
    "errors": {
      "type": "object",
      "additionalProperties": {}
    }
  },
  "required": [
    "title",
    "status"
  ]
}
503 Developer API rate limiter unavailable
application/problem+json

object

type
stringformat: "uri" · default: "about:blank"
titleобязательно
string
statusобязательно
integerminimum: 100 · maximum: 599
detail
string
instance
string
errors
object
JSON Schema
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "format": "uri",
      "default": "about:blank"
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer",
      "minimum": 100,
      "maximum": 599
    },
    "detail": {
      "type": "string"
    },
    "instance": {
      "type": "string"
    },
    "errors": {
      "type": "object",
      "additionalProperties": {}
    }
  },
  "required": [
    "title",
    "status"
  ]
}