# Import contacts from a CSV file

`POST /crm/import` · Rivier · contacts

Import contacts from a CSV file. A dry run first reports what would happen; nobody becomes subscribed by being in a file unless the importer states the basis.

- Scope: contacts:admin
- Graphql: Mutation.contactsImportRun
- Sdk: contacts.import.run
- Cli: contacts import run

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "csv": {
      "type": "string",
      "minLength": 1,
      "maxLength": 20000000
    },
    "mapping": {
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "maxLength": 60
      },
      "propertyNames": {
        "maxLength": 120
      }
    },
    "dryRun": {
      "type": "boolean",
      "default": true
    },
    "onExisting": {
      "type": "string",
      "enum": [
        "skip",
        "fill",
        "overwrite"
      ],
      "default": "fill"
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string",
        "maxLength": 40
      },
      "maxItems": 10
    },
    "source": {
      "type": "string",
      "maxLength": 80,
      "default": "import"
    },
    "country": {
      "type": "string",
      "minLength": 2,
      "maxLength": 2
    },
    "consent": {
      "type": "object",
      "properties": {
        "channel": {
          "type": "string",
          "enum": [
            "email",
            "sms",
            "whatsapp",
            "phone"
          ],
          "default": "email"
        },
        "purpose": {
          "type": "string",
          "default": "marketing"
        },
        "basis": {
          "type": "string",
          "minLength": 10,
          "maxLength": 500
        },
        "collectedAt": {
          "type": "string",
          "maxLength": 40
        },
        "policyVersion": {
          "type": "string",
          "maxLength": 40
        }
      },
      "required": [
        "basis"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "csv"
  ],
  "additionalProperties": false
}
```

## Responses

- `200`: 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/import' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "csv": "string"
}'
```
