> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendrealm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Look Up Or Upsert Contacts

> Resolve contacts by email without exposing email addresses in URLs.

## Look up by email

`POST /contacts/lookup`

```json theme={null}
{ "email": "olivia@example.com" }
```

The response is `200 OK` with `data: null` when no active contact exists.

## Upsert by email

`POST /contacts/upsert`

```json theme={null}
{
  "email": "olivia@example.com",
  "fields": {
    "first_name": "Olivia",
    "plan": "pro"
  }
}
```

Upsert merges provided fields, validates declared audience properties, and returns
the contact with `created: true` or `created: false`. Email is normalized per
project and concurrent requests resolve to one active contact.


## OpenAPI

````yaml api-reference/openapi.json POST /contacts/lookup
openapi: 3.0.1
info:
  title: Sendrealm API
  description: >-
    API for email, push, audience resources, domains, campaign drafts,
    templates, events, topics, and automations
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.sendrealm.com
security:
  - bearerAuth: []
paths:
  /contacts/lookup:
    post:
      summary: Look up a contact by email
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - email
              properties:
                email:
                  type: string
                  format: email
      responses:
        '200':
          description: Contact or null
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactLookupResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    ContactLookupResponse:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: integer
          description: HTTP response status code
        data:
          type: object
          nullable: true
          allOf:
            - $ref: '#/components/schemas/Contact'
    Contact:
      type: object
      properties:
        id:
          type: string
          format: uuid
        email:
          type: string
          format: email
        fields:
          $ref: '#/components/schemas/ContactFields'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - status
        - error
      properties:
        status:
          type: integer
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details:
              $ref: '#/components/schemas/JsonValue'
            issues:
              type: array
              items:
                $ref: '#/components/schemas/ValidationIssue'
    ContactFields:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/JsonPrimitive'
    JsonValue:
      oneOf:
        - type: string
          nullable: true
        - type: number
        - type: boolean
        - type: object
          additionalProperties:
            $ref: '#/components/schemas/JsonValue'
        - type: array
          items:
            $ref: '#/components/schemas/JsonValue'
    ValidationIssue:
      type: object
      required:
        - code
        - path
        - message
      properties:
        code:
          type: string
        path:
          type: string
          nullable: true
        message:
          type: string
    JsonPrimitive:
      oneOf:
        - type: string
          nullable: true
        - type: number
        - type: boolean
  responses:
    Unauthorized:
      description: Invalid or missing API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````