---
title: "Create a lead"
url: "https://real-estate-agency.apim.eu/apis/leads/versions/d1fa19e4-3a7d-4b6b-aac0-9ec016571b4b/operations/createLead"
---

> Full API specification: https://real-estate-agency.apim.eu/apis/leads/versions/d1fa19e4-3a7d-4b6b-aac0-9ec016571b4b.md

# Create a lead

`POST` `/leads`

Operation ID: `createLead`

## Request body (required)

Content types: `application/json`

## Responses

- `201` - Created
- `400` - The request doesn't match the schema

## OpenAPI definition

```yaml
openapi: 3.0.3
info:
  title: Leads & Inquiries
  version: 1.0.0
servers:
  - url: https://api.realestateagency.example/v1
    description: Production
  - url: https://sandbox.api.realestateagency.example/v1
    description: Sandbox
paths:
  /leads:
    post:
      tags:
        - Leads
      summary: Create a lead
      operationId: createLead
      security:
        - apiKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LeadInput"
            example:
              first_name: Anna
              last_name: Bergmann
              email: a.bergmann@example.org
              phone: +1 217 555 0142
              consent:
                purpose: property_referral
                granted_at: 2026-08-18T10:22:00Z
              search_profile:
                type:
                  - apartment
                locations:
                  - Springfield
                rooms_min: 3
                purchase_price_max_eur: 700000
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Lead"
        "400":
          $ref: "#/components/responses/ValidationError"
security:
  - apiKey: []
components:
  schemas:
    LeadInput:
      type: object
      required:
        - last_name
        - email
        - consent
      properties:
        first_name:
          type: string
          example: Anna
        last_name:
          type: string
          example: Bergmann
        email:
          type: string
          format: email
          example: a.bergmann@example.org
        phone:
          type: string
          example: +1 217 555 0142
        consent:
          $ref: "#/components/schemas/Consent"
        search_profile:
          $ref: "#/components/schemas/SearchProfile"
    Lead:
      allOf:
        - $ref: "#/components/schemas/LeadInput"
        - type: object
          properties:
            id:
              type: string
              example: lead_71ab
            retention_until:
              type: string
              format: date
              description: Automatically set deletion deadline. Anonymized after it passes.
              example: 2027-02-18
            created_at:
              type: string
              format: date-time
              example: 2026-08-18T10:22:04Z
    Consent:
      type: object
      description: Record of consent under applicable data protection law.
      required:
        - purpose
        - granted_at
      properties:
        purpose:
          type: string
          enum:
            - property_referral
            - newsletter
        granted_at:
          type: string
          format: date-time
          example: 2026-08-18T10:22:00Z
        revoked_at:
          type: string
          format: date-time
          nullable: true
          example: null
    SearchProfile:
      type: object
      properties:
        type:
          type: array
          items:
            type: string
            enum:
              - apartment
              - house
              - land
              - commercial
        locations:
          type: array
          items:
            type: string
            example: Springfield
        rooms_min:
          type: number
          format: float
          example: 3
        living_area_min_sqm:
          type: number
          format: float
          example: 75
        purchase_price_max_eur:
          type: integer
          example: 700000
        cold_rent_max_eur:
          type: integer
          example: 1600
        financing_proof:
          type: boolean
          example: false
    Error:
      type: object
      description: Uniform error format across all Real Estate Agency APIs.
      required:
        - code
        - message
      properties:
        code:
          type: string
          example: validation_failed
        message:
          type: string
          example: Consent is required to create a lead.
        details:
          type: array
          items:
            $ref: "#/components/schemas/ErrorDetail"
    ErrorDetail:
      type: object
      properties:
        field:
          type: string
          example: consent.purpose
        reason:
          type: string
          example: missing
  responses:
    ValidationError:
      description: The request doesn't match the schema
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: apikey
      description: |
        Every call carries an API key in the `apikey` header. You generate the
        key in the Real Estate portal under "My Apps"; it's shown exactly once.

        Each key has the scopes it's allowed to use attached to it. If one is
        missing, the API responds with `403` and `code: "scope_missing"`; the
        missing scope is in `details[].field`.
```
