LeadForm

/api/v1/lead_ads/lead_forms/<lead_form_id>.json

A resource that allows you to retrieve and update lead forms.

GET

Retrieving a single lead form

Request example


    GET /api/v1/lead_ads/lead_forms/17.json

Response example


    {
        "id": "17",
        "name": "My first lead form"
    }

Available fields are described in LeadForm.

Parameters

  • get_active_form_ad_plans — a flag indicating whether to return the IDs of active ad_plans for the form. If not specified, they are not returned by default.

    /api/v1/lead_ads/lead_forms/17.json?get_active_form_ad_plans=1

POST

Editing a lead form

Request example


    POST /api/v1/lead_ads/lead_forms/17.json
    {
        "name": "VK Ads. Updated lead form"
    }

Response example


    HTTP 200
    {
        "id": "17",
        "name": "VK Ads. Updated lead form",
        ...
    }

The contents of the contact_fields, result_info, agreement, notifications, and pages sections are fully replaced on update. For example, for a lead form with contact_fields:


    {
        "contact_fields": [
            "first_name",
            "phone",
            "city"
        ],
    }

the update request:


    {
        "contact_fields": [
            "first_name",
            "phone",
            "birth_date"
        ],
    }

will result in exactly this new contact_fields section after the update.

Possible response codes

  • 200 — lead form saved
  • 400 — validation error
  • 404 — lead form not found

Possible error codes

  • bad_value — invalid value format or type
  • required — field is required
  • required_value — a required value is expected
  • unallowed_value — value is not in the list of allowed values
  • bad_items — the list contains invalid values
  • max_value — string/list length/size is greater than the maximum
  • min_value — string/list length/size is less than the minimum
  • duplicate_value — the list contains duplicate values
  • bad_contact_field_value — the provided list of contact fields does not contain all required values

In general, an error message has the following format:


    {
        "error": {
            "fields": {
                "<field_name_1\>": {
                    "message": "<error_message_1\>",
                    "code": "<error_code_1\>"
                },
                "<field_name_2\>": {
                    "message": "<error_message_2\>",
                    "code": "<error_code_2\>"
                }
            },
            "message": "Validation failed",
            "code": "validation_failed"
        }
    }

where field_name_N is the name of the field where the error occurred, error_message_N is the error description, and error_code_N is the error code.

Example:


    {
        "error": {
            "fields": {
                "contact_fields": {
                    "message": "Provided contact fields do not contain required values",
                    "code": "bad_contact_field_value"
                }
            },
            "message": "Validation failed",
            "code": "validation_failed"
        }
    }