# Add a contact, or update the one that already has this email or number

`POST /crm/contacts` · Rivier · contacts

Add a contact, or update the one that already has this email or number.

- Scope: contacts:write
- Graphql: Mutation.contactsContactCreate
- Sdk: contacts.contact.create
- Cli: contacts contact create
- Events: contacts.contact.created

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "maxLength": 200
    },
    "firstName": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ]
    },
    "lastName": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ]
    },
    "email": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 320
        },
        {
          "type": "null"
        }
      ]
    },
    "phone": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 40
        },
        {
          "type": "null"
        }
      ]
    },
    "identities": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "pattern": "^(email|phone|whatsapp|handle:[a-z0-9_.-]{1,30}|external:[a-z0-9_.-]{1,30})$"
          },
          "value": {
            "type": "string",
            "minLength": 1,
            "maxLength": 320
          },
          "primary": {
            "type": "boolean"
          },
          "verified": {
            "type": "boolean"
          }
        },
        "required": [
          "kind",
          "value"
        ],
        "additionalProperties": false
      },
      "maxItems": 20
    },
    "companyId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ]
    },
    "company": {
      "type": "string",
      "maxLength": 200,
      "description": "A company name or domain; found or created"
    },
    "owner": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 200
        },
        {
          "type": "null"
        }
      ]
    },
    "lifecycle": {
      "type": "string",
      "enum": [
        "subscriber",
        "lead",
        "customer",
        "partner",
        "other"
      ]
    },
    "source": {
      "type": "string",
      "maxLength": 80
    },
    "language": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 20
        },
        {
          "type": "null"
        }
      ]
    },
    "country": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 2,
          "maxLength": 2
        },
        {
          "type": "null"
        }
      ]
    },
    "timezone": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 60
        },
        {
          "type": "null"
        }
      ]
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 40,
        "pattern": "^[\\p{L}\\p{N}][\\p{L}\\p{N} _.:/-]*$"
      },
      "maxItems": 50
    },
    "custom": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "type": "string",
            "maxLength": 2000
          },
          {
            "type": "number"
          },
          {
            "type": "boolean"
          },
          {
            "type": "null"
          }
        ]
      },
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9_]{0,39}$"
      }
    }
  },
  "additionalProperties": false
}
```

## Responses

- `201`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/crm/contacts' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "firstName": "string",
  "lastName": "string",
  "email": "string",
  "phone": "string",
  "identities": [
    {
      "kind": "string",
      "value": "string"
    }
  ],
  "companyId": "string",
  "company": "string"
}'
```
