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

# Update a contact

> Update or create a contact.

Update a contact by `email` or `userId`. You must provide one of these parameters.

If you want to update a contact's email address, the contact will first need a `userId` value. You can then make a request containing the `userId` field along with an updated email address.

This endpoint will create a contact if a matching contact does not already exist in your audience.

<Note>Provide either `email` or `userId` to identify the contact you want to update. If both are provided, the system will look for a contact with either a matching `email` or `userId` value. If a contact is found for one of the values (e.g. `email`), the other value (e.g. `userId`) will be updated. If a contact is not found, a new contact will be created using both `email` and `userId` values.</Note>


## OpenAPI

````yaml /openapi.json put /v1/contacts/update
openapi: 3.1.0
info:
  title: Loops OpenAPI Spec
  description: This is the OpenAPI Spec for the [Loops API](https://loops.so/docs/api).
  version: 1.21.0
servers:
  - url: https://app.loops.so/api
security: []
tags:
  - name: API key
  - name: Audience segments
    description: View audience segments
  - name: Campaigns
    description: Create and manage email campaigns
  - name: Campaign groups
    description: Organize campaigns into groups
  - name: Components
    description: View email components
  - name: Configuration
    description: View configuration settings
  - name: Contacts
    description: Manage contacts in your audience
  - name: Contact properties
    description: Manage contact properties
  - name: Email messages
    description: Manage email message content for campaigns
  - name: Events
    description: Trigger workflows with events
  - name: Event patterns
    description: View workflow event patterns
  - name: Mailing lists
    description: View mailing lists
  - name: Themes
    description: View email themes
  - name: Transactional emails
    description: Create, manage, and send transactional emails
  - name: Transactional groups
    description: Organize transactional emails into groups
  - name: Uploads
    description: Upload image assets
  - name: Workflows
    description: View and mutate workflow graphs
  - name: Workflow nodes
    description: View and mutate workflow nodes
paths:
  /v1/contacts/update:
    put:
      tags:
        - Contacts
      summary: Update a contact
      description: >-
        Update a contact by `email` or `userId`. You must provide one of these
        parameters.


        If you want to update a contact's email address, the contact will first
        need a `userId` value. You can then make a request containing the
        `userId` field along with an updated email address.


        This endpoint will create a contact if a matching contact does not
        already exist in your audience.


        Provide either `email` or `userId` to identify the contact you want to
        update. If both are provided, the system will look for a contact with
        either a matching `email` or `userId` value. If a contact is found for
        one of the values (e.g. `email`), the other value (e.g. `userId`) will
        be updated. If a contact is not found, a new contact will be created
        using both `email` and `userId` values.
      requestBody:
        description: >-
          You can add custom contact properties as keys in this request (of type
          `string`, `number`, `boolean` or `date`. [See available date
          formats](https://loops.so/docs/contacts/properties#dates)). Make sure
          to create the properties in Loops before using them in API calls.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ContactUpdateRequest'
        required: true
      responses:
        '200':
          description: Successful update.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactSuccessResponse'
        '400':
          description: Bad request (e.g. `email` or `userId` are missing).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactFailureResponse'
        '405':
          description: Wrong HTTP request method.
      security:
        - apiKey: []
components:
  schemas:
    ContactUpdateRequest:
      allOf:
        - $ref: '#/components/schemas/ContactFields'
        - type: object
          properties:
            email:
              type: string
              description: >-
                The contact's email address. **Required if `userId` is not
                provided.**
            subscribed:
              type: boolean
              description: >-
                Whether the contact will receive campaign and workflow emails.
                We recommend leaving this field out of your update requests
                unless you specifically want to unsubscribe (`false`) or
                re-subscribe (`true`) a contact. All new contacts are subscribed
                by default.
            userId:
              type: string
              description: >-
                The contact's unique user ID. **Required if `email` is not
                provided.**
          anyOf:
            - required:
                - email
            - required:
                - userId
      additionalProperties:
        oneOf:
          - type: string
          - type: number
          - type: boolean
    ContactSuccessResponse:
      type: object
      properties:
        success:
          type: boolean
          examples:
            - true
        id:
          type: string
      required:
        - success
        - id
    ContactFailureResponse:
      type: object
      properties:
        success:
          type: boolean
          examples:
            - false
        message:
          type: string
      required:
        - success
        - message
    ContactFields:
      type: object
      properties:
        email:
          type: string
          description: The contact's email address.
        firstName:
          type: string
          description: The contact's first name.
        lastName:
          type: string
          description: The contact's last name.
        source:
          type: string
          description: A custom source value to replace the default “API”.
        subscribed:
          type: boolean
          description: >-
            Whether the contact will receive campaign and workflow emails. All
            new contacts are subscribed by default.
        userGroup:
          type: string
          description: >-
            You can use groups to segment users when sending emails. Currently,
            a contact can only be in one user group. [Read
            more](/contacts/properties#user-group)
        userId:
          type: string
          description: A unique user ID (for example, from an external application).
        mailingLists:
          $ref: '#/components/schemas/MailingListSubscriptions'
      additionalProperties:
        oneOf:
          - type: string
          - type: number
          - type: boolean
    MailingListSubscriptions:
      type: object
      description: >-
        Manage mailing list subscriptions.


        Include key-value pairs of mailing list IDs and a `boolean` denoting if
        the contact should be added (`true`) or removed (`false`) from the list.
      examples:
        - cm06f5v0e45nf0ml5754o9cix: true
          cm16k73gq014h0mmj5b6jdi9r: false
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

## Related topics

- [Contacts API examples](/docs/api-reference/examples/contacts.md)
- [Recipe: SaaS customer lifecycle emails](/docs/guides/lifecycle-emails.md)
- [Bubble integration](/docs/integrations/bubble.md)
- [Zapier integration](/docs/integrations/zapier.md)
- [PostHog](/docs/integrations/posthog.md)
