# Create Members Import Request

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v3/{loyalty_club_slug}/members/imports:
    post:
      summary: Create Members Import Request
      deprecated: false
      description: >-
        Creates new members or updates existing ones (based on `msisdn` and
        `e-mail` identifiers).


        There is a maximum number of members that can be sent in one request
        (1000). So, if you intend to import more than

        that, you may want to identify all bulks with the same `import_id` and
        pass consequent `request_number` to each of them.


        ## Body Parameters


        | Parameter                | Required? | Default        |
        Description                                                                                                                                                  
        | Type                            |

        | ------------------------ | --------- | --------------
        |---------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|

        | import_id                | no        | auto-generated | When you're
        making more than one call you can consider adding it. Otherwise it will
        be
        auto-generated                                                         |
        String                          |

        | request_number           | no        | -              | A number that
        you can use for bulk identification in "Status" endpoint. It's up to you
        to provide it's uniqueness. Useless without specifying `import_id`     |
        Integer                         |

        | members                  | yes       | -              | Array with
        members payloads - See
        below                                                                                                                      
        | object[]                        |

        | operation                | no        | `"create"`     | Should members
        be created or
        updated                                                                                                                         
        | enum: ['create', 'update']      |

        | member_identifier_type   | no        | `"id"`         | (for
        `"update"` operation) Which member property should be used to identify
        member for
        update                                                                 |
        enum: ['id', 'email', 'msisdn'] |

        | multi_values_update_mode | no        | `"replace"`    | (for
        `"update"` operation) When "append" is given, multi-value member
        attributes (like arrays) are appended to existing ones. In other case,
        they're replaced | enum: ['update', 'append']      |


        ### Members Array 


        General requirements:


        * all members must have unique identifiers (`msisdn` or `email`)

        * maximum number of items in array is 1000


        Key | Required? | Default | Description | Type

        --- | --- | --- | --- | ---

        properties | yes | - | JSON with properties for member (see: [Member
        model](doc-342131#member) | JSON Object

        properties\['msisdn'\] | yes* | none | Unique member's msisdn as defined
        [here](doc-341641#msisdn)) Example: `4740769126`.| string

        properties\['email'\] | yes* | none | Member's email | string

        password | no | null | Member’s password. Not required, but user may not
        be able to log in without this | String

        sms_enabled | no | true | Should SMS channel be enabled for member? |
        Boolean

        email_enabled | no | true | Should email channel be enabled for member?
        | Boolean

        push_enabled | no | true | Should push channel be enabled for member? |
        Boolean

        optin_channel | no | "import"** | Source of member | String

        optin_subchannel | no | import's id** | Subsource of member| String

        consents | no | {} | Members consents | See [Member's consents JSON
        model](doc-342131#members-consents-json-model) | JSON object


        &ast; At least one of those properties must be provided


        &ast;&ast; When those member attributes are missing on creation,
        defaults will be used. When on update, they won't be overwritten.


        ## Response Body


        Key | Description | Type

        --- | --- | ---

        import_id | Identifier for import status checking (either provided by
        you or auto-generated) | String


        ## Error Responses


        Status | Reason | Description

        --------- | ----------- | -----------

        `422` | Invalid payload | Returns error object - see below


        ### Invalid Payload Error (JSON object)


        When payload is invalid, an object is returned: `{"error" => <reason>}`


        Possible reasons are:


        Code | Description

        ---- | -----------

        `duplicated_emails` | At least two members in payload share same email

        `duplicated_msisdns` | At least two members in payload share same msisdn

        `members_size_incorrect` | Members number in payload exceeds maximum
        (1000)

        `members_empty` | Payload is empty

        `missing_identifier` | At least one member in payload misses required
        identifier (depends on Loyalty Club)

        `invalid_operation` | Specified operation is not supported

        `invalid_member_identifier_type` | Specified identifier type is invalid
        or unavailable in Loyalty Club


        ## Example


        ```shell

        curl -X POST \
            "https://api.mpc.placewise.com/v3/infinity-mall/members/imports" \
            -H 'content-type: application/json' \
            -H 'x-client-authorization: B7t9U9tsoWsGhrv2ouUoSqpM' \
            -H 'x-product-name: default' \
            -H 'x-user-agent: CURL manual test'
          -d \
            '{
              "import_id": "import_21",
              "request_number": 3,
              "operation": "create",
              "members": [
                {
                  "properties": { "email": "foo@bar.baz" },
                  "password": "pass",
                  "sms_enabled": true,
                  "email_enabled": true,
                  "push_enabled": true,
                  "optin_channel": true,
                  "optin_subchannel": true,
                  "created_at": "foo",
                  "updated_at": "bar",
                  "consents": { "email_marketing": { "status": true } }
                }
              ]
            }'    
        ```


        When successful, returns JSON structured like this:


        ```json

        {
          "import_id": "a9a00143-6488-4d4f-87d4-29c2da02d678"
        }

        ```


        When input is invalid, returns the error object:


        ```json

        {
          "error": "duplicated_msisdns"
        }

        ```
      tags:
        - API Reference/Management API/Members/Imports
      parameters:
        - name: loyalty_club_slug
          in: path
          description: ''
          required: true
          example: '{{LOYALTY_CLUB_SLUG}}'
          schema:
            type: string
        - name: Content-Type
          in: header
          description: '[Details](doc-341635)'
          required: true
          example: application/json
          schema:
            type: string
            default: application/json
            const: application/json
        - name: X-User-Agent
          in: header
          description: Arbitrary identifier of your client. [Details](doc-341635)
          required: true
          example: '{{X_USER_AGENT}}'
          schema:
            type: string
            default: '{{X_USER_AGENT}}'
        - name: X-Product-Name
          in: header
          description: API Product for API context. [Details](doc-341635)
          required: true
          example: '{{PRODUCT_NAME}}'
          schema:
            type: string
            default: '{{PRODUCT_NAME}}'
        - name: X-Loyalty-Club-Slug
          in: header
          description: LoyaltyClub for API context. [Details](doc-342138)
          required: false
          example: '{{LOYALTY_CLUB_SLUG}}'
          schema:
            type: string
            default: '{{LOYALTY_CLUB_SLUG}}'
        - name: X-Customer
          in: header
          description: Customer for API context.  [Details](doc-342139)
          required: false
          example: '{{CUSTOMER_ID}}'
          schema:
            type: string
            default: '{{CUSTOMER_ID}}'
        - name: Authorization
          in: header
          description: '[Member](doc-342129) or [User](doc-342130) Authorization.'
          required: false
          example: Bearer {{_OAUTH_TOKEN}}
          schema:
            type: string
            default: Bearer {{_OAUTH_TOKEN}}
        - name: X-Client-Authorization
          in: header
          description: '[Token](doc-342128) Authorization.'
          example: '{{API_TOKEN}}'
          schema:
            type: string
            default: '{{API_TOKEN}}'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
          headers: {}
          x-apidog-name: Success
      security: []
      x-apidog-folder: API Reference/Management API/Members/Imports
      x-apidog-status: pending
      x-run-in-apidog: https://app.eu.apidog.com/web/project/346351/apis/api-3511022-run
components:
  schemas: {}
  securitySchemes: {}
servers:
  - url: https://api.mpc.dev.placewise.com
    description: Staging
security: []

```