---
title: Create leads
slug: mihai-tests/create-leads
createdAt: 2024-10-17T06:33:52.755Z
---

{
  "id": "5gEqxhPCgqhcoH8cYMaF5",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "/api/v1/leads/process/",
    "servers": [],
    "name": "Create leads",
    "description": "Process leads.",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "kind": "required",
          "name": "X-Product-Id",
          "type": "string",
          "description": "Pass in product Id."
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "description": "",
          "customType": "Lead",
          "schema": [
            {
              "name": "email",
              "kind": "optional",
              "type": "string<email>",
              "example": ""
            },
            {
              "name": "first_name",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "last_name",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "mobile",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "country",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "post_code",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "lead_types",
              "kind": "optional",
              "type": "array",
              "description": "",
              "modelRef": "#/components/schemas/LeadsType",
              "customType": "LeadsType[]",
              "schema": [
                {
                  "name": "type",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "advice_type",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "purpose",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                }
              ]
            }
          ],
          "modelRef": "#/components/schemas/Lead",
          "isExpanded": true
        }
      ],
      "formDataParameters": [
        {
          "name": "email",
          "kind": "optional",
          "type": "string<email>",
          "example": ""
        },
        {
          "name": "first_name",
          "kind": "optional",
          "type": "string",
          "example": ""
        },
        {
          "name": "last_name",
          "kind": "optional",
          "type": "string",
          "example": ""
        },
        {
          "name": "mobile",
          "kind": "optional",
          "type": "string",
          "example": ""
        },
        {
          "name": "country",
          "kind": "optional",
          "type": "string",
          "example": ""
        },
        {
          "name": "post_code",
          "kind": "optional",
          "type": "string",
          "example": ""
        },
        {
          "name": "lead_types",
          "kind": "optional",
          "type": "array",
          "description": "",
          "modelRef": "#/components/schemas/LeadsType",
          "customType": "LeadsType[]",
          "schema": [
            {
              "name": "type",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "advice_type",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "purpose",
              "kind": "optional",
              "type": "string",
              "example": ""
            }
          ]
        }
      ],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "Created",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "leads",
                "kind": "optional",
                "type": "array",
                "description": "",
                "modelRef": "#/components/schemas/LeadResponse",
                "customType": "LeadResponse[]",
                "schema": [
                  {
                    "name": "email",
                    "kind": "optional",
                    "type": "string<email>",
                    "example": "user@example.com"
                  },
                  {
                    "name": "reference_id",
                    "kind": "optional",
                    "type": "string",
                    "example": "ID_12345"
                  }
                ]
              }
            ],
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "409",
        "description": "Conflict",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "object",
                "kind": "optional",
                "type": "object",
                "description": "",
                "example": "{\"email\":\"user@example.com\",\"reference_id\":\"ID_12345\"}",
                "modelRef": "#/components/schemas/LeadResponse",
                "customType": "LeadResponse",
                "schema": [
                  {
                    "name": "email",
                    "kind": "optional",
                    "type": "string<email>",
                    "example": "user@example.com"
                  },
                  {
                    "name": "reference_id",
                    "kind": "optional",
                    "type": "string",
                    "example": "ID_12345"
                  }
                ]
              },
              {
                "name": "status_code",
                "kind": "optional",
                "type": "",
                "example": "",
                "default": 409
              },
              {
                "name": "message",
                "kind": "optional",
                "type": "",
                "example": "",
                "default": {
                  "detail": "Data conflict detected: This member already exists.",
                  "code": "elmo_validation_error"
                }
              }
            ],
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "NZ26yehUtHpXJDzXDaPbM",
          "language": "curl",
          "label": "cURL",
          "code": "curl --location '/api/v1/leads/process/' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--data '{\n  \"email\": \"\",\n  \"first_name\": \"\",\n  \"last_name\": \"\",\n  \"mobile\": \"\",\n  \"country\": \"\",\n  \"post_code\": \"\",\n  \"lead_types\": [\n    {\n      \"type\": \"\",\n      \"advice_type\": \"\",\n      \"purpose\": \"\"\n    }\n  ]\n}'"
        },
        {
          "id": "qnztEmPabXPd1DAeYgZHH",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"Content-Type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"email\": \"\",\n   \"first_name\": \"\",\n   \"last_name\": \"\",\n   \"mobile\": \"\",\n   \"country\": \"\",\n   \"post_code\": \"\",\n   \"lead_types\": [\n      {\n         \"type\": \"\",\n         \"advice_type\": \"\",\n         \"purpose\": \"\"\n      }\n   ]\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"/api/v1/leads/process/\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "i-dhWLoNPEITGgGWHV4Zv",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"/api/v1/leads/process/\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"Accept\"] = \"application/json\"\nrequest[\"Content-Type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"email\": \"\",\n   \"first_name\": \"\",\n   \"last_name\": \"\",\n   \"mobile\": \"\",\n   \"country\": \"\",\n   \"post_code\": \"\",\n   \"lead_types\": [\n      {\n         \"type\": \"\",\n         \"advice_type\": \"\",\n         \"purpose\": \"\"\n      }\n   ]\n})\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "uthZhgI9IL_nfN2zYMyVk",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"/api/v1/leads/process/\"\n\npayload = json.dumps({\n   \"email\": \"\",\n   \"first_name\": \"\",\n   \"last_name\": \"\",\n   \"mobile\": \"\",\n   \"country\": \"\",\n   \"post_code\": \"\",\n   \"lead_types\": [\n      {\n         \"type\": \"\",\n         \"advice_type\": \"\",\n         \"purpose\": \"\"\n      }\n   ]\n})\nheaders = {\n   'Accept': 'application/json',\n   'Content-Type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "NZ26yehUtHpXJDzXDaPbM"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-201",
          "language": "201",
          "code": "// Created\n{\n  \"leads\": [\n    {\n      \"email\": \"user@example.com\",\n      \"reference_id\": \"ID_12345\"\n    }\n  ]\n}"
        },
        {
          "id": "response-1-409",
          "language": "409",
          "code": "// Conflict\n{\n  \"object\": {\n    \"email\": \"user@example.com\",\n    \"reference_id\": \"ID_12345\"\n  },\n  \"status_code\": \"\",\n  \"message\": \"\"\n}"
        }
      ],
      "selectedLanguageId": "response-0-201"
    }
  },
  "children": [
    {
      "id": "1iJ3j_CnisqnNcUpQCy94",
      "type": "paragraph",
      "children": [
        {
          "text": "Process leads."
        }
      ]
    }
  ]
}