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

# Import

> Used to create new user profiles and/or set attributes for these profiles.

<br>

<p>This method is used to import or update the system fields for user profiles as well as any custom profile attributes, similar to importing a <a href="https://docs.xtremepush.com/docs/user-profile-create">CSV using the interface</a> and using the same field names listed in the <a href="https://docs.xtremepush.com/docs/attributes-tags">attributes guide</a>.</p>

<p>Further information on user profiles, device profiles and attributes can be found in the <a href="https://docs.xtremepush.com/docs/users">guide on user data</a>.</p>

<br>

<p>The attributes being updated are listed in the <code>columns</code> parameter, and the individual values are set in an array of arrays in the <code>rows</code> parameter, keeping the same column order. There are a number of reserved field names you can use in the list of column headers to set system user profile attributes.</p>

<br>

<p>You must set a <code>user_id</code> and if setting <code>email</code> or <code>mobile_number</code>, the email and SMS subscription status must also be set. Custom Profile Attributes can also be set by adding the attribute key name in the list of column headers.</p>

<p>If you are setting a JSON value into a custom attribute, it must be provided as a JSON string, so the value must be escaped.</p>

<br>

<p><strong>Note:</strong> For optimal imports, limit your use of this method to 10,000 records in a single request. If you are importing more records, batch the data into multiple requests.</p>

<br>

## Asynchronous mode

<p>By default, this method will process records asynchronously, when 100 records or more are given. This allows the API request to respond more quickly, and the import process to be optimised for larger datasets.</p>

<p>For asynchronous imports, a <code>202</code> response code is given. The task ID in the response can be used to check the import status using the <a href="https://docs.xtremepush.com/reference/task-info">Task Info method</a>.</p>

## OpenAPI

````json POST /import/profile
{
  "openapi": "3.1.0",
  "info": {
    "title": "external-api",
    "version": "1"
  },
  "servers": [
    {
      "url": "https://api.eu.xtremepush.com/api/external"
    }
  ],
  "paths": {
    "/import/profile": {
      "post": {
        "summary": "Import",
        "description": "Used to create new user profiles and/or set attributes for these profiles.\n\n<br>\n\n<p>This method is used to import or update the system fields for user profiles as well as any custom profile attributes, similar to importing a <a href=\"https://docs.xtremepush.com/docs/user-profile-create\">CSV using the interface</a> and using the same field names listed in the <a href=\"https://docs.xtremepush.com/docs/attributes-tags\">attributes guide</a>.</p>\n\n<p>Further information on user profiles, device profiles and attributes can be found in the <a href=\"https://docs.xtremepush.com/docs/users\">guide on user data</a>.</p>\n\n<br>\n\n<p>The attributes being updated are listed in the <code>columns</code> parameter, and the individual values are set in an array of arrays in the <code>rows</code> parameter, keeping the same column order. There are a number of reserved field names you can use in the list of column headers to set system user profile attributes.</p>\n\n<br>\n\n<p>You must set a <code>user_id</code> and if setting <code>email</code> or <code>mobile_number</code>, the email and SMS subscription status must also be set. Custom Profile Attributes can also be set by adding the attribute key name in the list of column headers.</p>\n\n<p>If you are setting a JSON value into a custom attribute, it must be provided as a JSON string, so the value must be escaped.</p>\n\n<br>\n\n<p><strong>Note:</strong> For optimal imports, limit your use of this method to 10,000 records in a single request. If you are importing more records, batch the data into multiple requests.</p>\n\n<br>\n\n## Asynchronous mode\n\n<p>By default, this method will process records asynchronously, when 100 records or more are given. This allows the API request to respond more quickly, and the import process to be optimised for larger datasets.</p>\n\n<p>For asynchronous imports, a <code>202</code> response code is given. The task ID in the response can be used to check the import status using the <a href=\"https://docs.xtremepush.com/reference/task-info\">Task Info method</a>.</p>",
        "operationId": "user-profile-import",
        "deprecated": "false",
        "requestBody": {
          "required": "true",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "apptoken",
                  "columns",
                  "rows"
                ],
                "properties": {
                  "apptoken": {
                    "type": "string",
                    "description": "Your App Token"
                  },
                  "columns": {
                    "type": "array",
                    "description": "The attributes you would like to set, must include either *user_id* or *email*",
                    "items": {
                      "type": "string"
                    }
                  },
                  "rows": {
                    "type": "string",
                    "format": "json",
                    "description": "The values for the attributes per user. Array of rows, where each row is an array of values."
                  },
                  "async": {
                    "type": "boolean",
                    "description": "Optional. Default enabled for requests with 100 records or more. If set to 0 your request will be processed completely before API response is returned. This should only be used during development for small numbers of records. In most cases this parameter should be omitted."
                  }
                }
              },
              "examples": {
                "Import user profiles with email and SMS": {
                  "value": {
                    "apptoken": "YOUR_APPTOKEN",
                    "columns": [
                      "user_id",
                      "email",
                      "email_subscription",
                      "mobile_number",
                      "sms_subscription",
                      "first_name"
                    ],
                    "rows": [
                      [
                        "fe56bc676be78",
                        "sam@example.com",
                        "1",
                        "353850123456",
                        "1",
                        "Sam"
                      ],
                      [
                        "fe56bc676be79",
                        "joe@example.com",
                        "1",
                        "447700900900",
                        "1",
                        "Joe"
                      ]
                    ]
                  }
                },
                "Import using device_id": {
                  "value": {
                    "apptoken": "YOUR_APPTOKEN",
                    "columns": [
                      "device_id",
                      "language",
                      "timezone",
                      "country",
                      "region",
                      "first_name"
                    ],
                    "rows": [
                      [
                        "12345",
                        "en",
                        "Europe/Dublin",
                        "Ireland",
                        "Europe",
                        "Sam"
                      ],
                      [
                        "12346",
                        "en",
                        "Europe/London",
                        "UK",
                        "Europe",
                        "Joe"
                      ]
                    ]
                  }
                },
                "Import array attribute": {
                  "value": {
                    "apptoken": "YOUR_APPTOKEN",
                    "columns": [
                      "user_id",
                      "order"
                    ],
                    "rows": [
                      [
                        "user",
                        "[\"frapuccino\", \"iced latte\"]"
                      ]
                    ]
                  }
                },
                "Import JSON object attribute": {
                  "value": {
                    "apptoken": "YOUR_APPTOKEN",
                    "columns": [
                      "user_id",
                      "order"
                    ],
                    "rows": [
                      [
                        "user1",
                        "{\"order_total\":12.34, \"item_count\":3, \"item_name\":\"socks\", \"properties\": {\"colour\":\"red\", \"size\":\"M\"}}"
                      ]
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": "true",
                      "default": "true"
                    },
                    "code": {
                      "type": "integer",
                      "example": "200",
                      "default": "0"
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "success": "true",
                      "code": "200"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "202",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": "true",
                      "default": "true"
                    },
                    "code": {
                      "type": "integer",
                      "example": "202",
                      "default": "0"
                    },
                    "task_id": {
                      "type": "integer",
                      "example": "123456",
                      "default": "0"
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "success": "true",
                      "code": "202",
                      "task_id": "123456"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": "false",
                      "default": "true"
                    },
                    "code": {
                      "type": "integer",
                      "example": "400",
                      "default": "0"
                    },
                    "message": {
                      "type": "string",
                      "example": "General error information"
                    },
                    "errors": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "text": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "Result": {
                    "value": {
                      "success": "false",
                      "code": "400",
                      "message": "General error information"
                    }
                  }
                }
              }
            }
          }
        },
        "tags": [
          "User Profile Methods"
        ]
      }
    }
  }
}
````

