# Authenticate as Profile

- Operation ID: `authenticateViaServerV2`
- HTTP method: `POST`
- Path: `/sauth/v2/auth/server/login/client`
- [Human-readable API reference](https://hub.synerise.com/api-reference/authorization#tag/Authorization-(deprecated)/operation/authenticateViaServerV2)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /sauth/v2/auth/server/login/client:
    post:
      deprecated: true
      tags:
        - Authorization (deprecated)
      summary: Authenticate as Profile
      description: |
        This method is deprecated. Use [the v3 method](#operation/authenticateViaServerV3) instead.

        Obtain a new JWT for a Profile. It is designed to be used from backend server. If an account for the Profile does not exist and the `identityProvider` is different than `SYNERISE`, this request creates an account.


        ---

        **API consumer:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>

        **API key permission required:** `SAUTH_SERVER_LOGIN_CLIENT_CREATE`
      operationId: authenticateViaServerV2
      requestBody:
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  required:
                    - ipAddress
                  properties:
                    ipAddress:
                      type: string
                      description: The IP address of the client device that is logging in.
                - type: object
                  required:
                    - apiKey
                    - identityProvider
                  properties:
                    apiKey:
                      type: string
                      description: Profile (formerly "Client") API key
                    identityProvider:
                      type: string
                      description: The identity provider.
                      enum:
                        - SYNERISE
                        - FACEBOOK
                        - OAUTH
                        - APPLE
                        - GOOGLE
                        - UNKNOWN
                    identityProviderToken:
                      type: string
                      description: Third-party authentication token used to authenticate with the Identity Provider. Required if `identityProvider` is different than `SYNERISE`.
                    email:
                      type: string
                      description: Profile email. Required if `identityProvider` is `SYNERISE` and email is the unique identifier (default setting).
                    customId:
                      description: Profile customId. Required if `identityProvider` is `SYNERISE` and customId is the unique identifier (see https://hub.synerise.com/docs/settings/configuration/non-unique-emails/).
                    password:
                      type: string
                      description: Profile password. Required if `identityProvider` is `SYNERISE`.
                    uuid:
                      type: string
                      description: Profile UUID. Required if `identityProvider` is `SYNERISE`.
                    deviceId:
                      type: string
                      description: |
                        Unique Android or iOS device ID.

                        We recommend sending this attribute every time, to assign a web push registration to the device.

                        Required when any form of [unknown device control](https://hub.synerise.com/docs/settings/tool/iam-for-apps/access/#unknown-device-control) is enabled.
                    agreements:
                      description: |-
                        Marketing agreements of the Profile.

                        You can also pass the values as strings (`"true"`;`"TRUE"`;`"True"`/`"false"`;`"FALSE"`;`"False"`) or integers (`1` for true and `0` for false).
                      type: object
                      properties:
                        email:
                          type: boolean
                          description: Permission to receive marketing information by email
                          default: true
                        sms:
                          type: boolean
                          description: Permission to receive marketing information by SMS
                          default: true
                        push:
                          type: boolean
                          description: Permission to receive push notifications
                          default: true
                        bluetooth:
                          type: boolean
                          deprecated: true
                          description: This field is ignored.
                          default: false
                        rfid:
                          type: boolean
                          deprecated: true
                          description: This field is ignored.
                          default: false
                        wifi:
                          type: boolean
                          deprecated: true
                          description: This field is ignored.
                          default: false
                        whatsApp:
                          type: boolean
                          description: Permission to receive WhatsApp messages
                          default: false
                      example:
                        email: true
                        sms: true
                        push: true
                        bluetooth: false
                        rfid: false
                        wifi: false
                    attributes:
                      type: object
                      description: |
                        Custom attributes (with any names)

                        <strong><span style="color:red">WARNING<span></strong>: Some attributes cannot be sent in this object and will be ignored. Some of these are reserved for system use, and others must be sent as properties of the profile in the root object of the request body instead of inside the `attributes` object.

                        <details><summary><span style="background:red;color:white">Click to expand the list of reserved attributes</span></summary>
                        <code>email</code><br><code>id</code><br><code>clientId</code><br><code>phone</code><br><code>customId</code><br><code>uuid</code><br><code>firstName</code><br><code>lastName</code><br>
                        <code>displayName</code><br><code>company</code><br><code>address</code><br><code>city</code><br><code>province</code><br><code>zipCode</code><br><code>countryCode</code><br>
                        <code>birthDate</code><br><code>sex</code><br><code>avatarUrl</code><br><code>anonymous</code><br><code>agreements</code><br><code>tags</code><br><code>businessProfileId</code><br>
                        <code>time</code><br><code>ip</code><br><code>source</code><br><code>newsletter_agreement</code><br><code>custom_identify</code><br><code>firstname</code><br>
                        <code>lastname</code><br><code>created</code><br><code>updated</code><br><code>last_activity_date</code><br><code>birthdate</code><br><code>external_avatar_url</code><br>
                        <code>displayname</code><br><code>receive_smses</code><br><code>receive_push_messages</code><br><code>receive_webpush_messages</code><br>
                        <code>receive_btooth_messages</code><br><code>receive_rfid_messages</code><br><code>receive_wifi_messages</code><br><code>receive_whatsapp_messages</code><br><code>whatsapp_id</code><br>
                        <code>zipCode</code><br><code>anonymous_type</code><br><code>country_id</code><br><code>geo_loc_country</code><br><code>geo_loc_isp</code><br>
                        <code>geo_loc_lat</code><br><code>geo_loc_lon</code><br><code>club_card_id</code><br><code>type</code><br><code>confirmed</code><br><code>facebookId</code><br><code>deletedAt</code><br><code>deleted_unique</code><br><code>status</code><br><code>recognized</code><br><code>previous_clients</code><br><code>testProfile</code><br>
                        <code>apikey</code><br><code>apiKey</code><br><code>ApiKey</code><br><code>Apikey</code><br><code>tracker</code><br><code>snr_sdk_version</code><br>
                        <code>eventCreateTime</code><br><code>correlationId</code>
                        </details>
                      additionalProperties:
                        description: Can be numbers, strings, or booleans.
                    tags:
                      type: array
                      description: Tags can be used to group Profile accounts.
                      items:
                        type: string
                  title: AuthenticationRequestV2_and_3
      responses:
        "200":
          description: Profile authorization token
          content:
            application/json:
              schema:
                type: object
                properties:
                  token:
                    type: string
                    description: "[JWT](https://jwt.io/) token"
                  expiration:
                    type: integer
                    example: 1649283173
                  created:
                    type: integer
                    example: 1649277173668
                  origin:
                    type: string
                    example: SYNERISE
                  customId:
                    type: string
                    example: card123
                  realm:
                    type: string
                    example: client
              example:
                token: eyJhbGciOiJSUzUxMiJ9.eyJzdinvalidwYmZkM2FkNDg2ZjQ3ZGRiMjE5MSIsImF1ZCI6IkFQSSIsInJsbSI6ImFub255bW91c19jbGllbnQiLCJjdGQiOjE1NTMwMDQxNTkxNTEsImVtbCI6IjYyMjM3NmY4LTAwMDAtMjIyMi1kN2Y5LTA3MGZhOTU2ZTk2M0Bhbm9ueW1vdXMuaW52YWxpZCIsImF1dGgiOiJINHNJQUFBQUFBQUFBSXVPQlFBcHUwd05BZ0FBQUE9PSIsImlzcyI6IlN5bmVyaXNlIiwiYnBpIjo0OCwiY2xJZCI6NDMzMjMwMjg4LCJleHAiOjE1NTMwMDcxNTksImFwayI6IjVBRUFBM0Q1LUUxNDctQzdFQi1ENTlFLUJDRjUwMTA5QTNEMSJ9.QOmSqrneR4mJFv4JdxTYsw_wGcDawDsVQuB-GVTcPPwijiP7lQ_Jzqq2Mypg1BS6WFlfGB8fzqCY9iMF_TdtjmoB4xBrY95ylU8L9qto-9Cw5x5TURkfxq31eryiHe2IteRAEtoVzYg2_s9QhlH6ANVcFOVp8dMno0V9bfMYfeSQa3FkjEbxFsseHkMOiADmp9-tOGtLXO942Ir-2W_Hz3Utlpt4erz0dVJBw8a-mFavPA8EEDWR7ACJNocrVHFkS3wFISh3LqLn6KkXiowaynKlJOEHGctuahzKmF3ZOJ1BvGgKohxF9OXvQs9IdmCfWhYsLr5Q2p04TJJ-MyvTipuggKVioh8mHmOFdfnN-Zused6tXzhZtKPUWTmM8cBKoAOBHExxcMQ8SVSjxnw_7_eLKm7S2wNpu0V-tiPZPCH4wYZXtWBYjmfy0V9ydjXnNunXfgxKixLeFNnONUXxEuqPLvM_xAuonQBXVN4nYrgJv8p8U6_ZlGMPjJq1szfcuBZnzI34LSEWx_nSof0XC5Czm8iG_ihG8naivNWS8h-Q-qKMP_3PPFsLSH4Egh03pH93EJUuNAeSO4RGfUX1wzMvrv1nBC1SM660uFMbq-wkplFBbKnHKMYe-qRs1-lZPG5PwPWJJdpGqOUzbnoMOJYmiq06OHHVQyJSkcEHLCk
        "400":
          description: Request failed, see error message for details
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      error:
                        type: string
                        description: Summary of the error
                      message:
                        type: string
                        description: Description of the problem
                      errors:
                        type: array
                        description: An array of detailed error messages, if applicable
                        items:
                          type: object
                          properties:
                            code:
                              type: integer
                              description: Error code
                            field:
                              type: string
                              description: Name of the field that did not pass validation
                            message:
                              type: string
                              description: Details of the problem
                            rejectedValue:
                              description: The value that did not pass validation
                              anyOf:
                                - type: string
                                - type: number
                                - type: integer
                                - type: boolean
                                - type: array
                                  items: {}
                                - type: object
                      status:
                        type: integer
                        format: int32
                        description: Status code
                      timestamp:
                        type: string
                        description: Time when the message was sent
                      path:
                        type: string
                        description: URL of the requested resource
                      traceId:
                        type: string
                        description: ID for debugging
                  - type: object
                    properties:
                      errorCode:
                        type: string
                        description: |
                          Error code, if applicable.
                          - `SAU-601`: Device ID is required and missing
        "401":
          description: Unauthorized.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  errors:
                    type: array
                    description: An array of detailed error messages, if applicable
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                          description: Error code
                        field:
                          type: string
                          description: Name of the field that did not pass validation
                        message:
                          type: string
                          description: Details of the problem
                        rejectedValue:
                          description: The value that did not pass validation
                          anyOf:
                            - type: string
                            - type: number
                            - type: integer
                            - type: boolean
                            - type: array
                              items: {}
                            - type: object
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  path:
                    type: string
                    description: URL of the requested resource
                  traceId:
                    type: string
                    description: ID for debugging
              example:
                timestamp: 2018-06-07T07:17:41.734+00:00
                status: 401
                error: Unauthorized
                message: Access denied
                path: /v3/auth/login/client
                traceId: 61b4aa7c0cb1167a
        "403":
          description: Authentication failed, see error message for details
          content:
            application/json:
              schema:
                allOf:
                  - type: object
                    properties:
                      error:
                        type: string
                        description: Summary of the error
                      message:
                        type: string
                        description: Description of the problem
                      errors:
                        type: array
                        description: An array of detailed error messages, if applicable
                        items:
                          type: object
                          properties:
                            code:
                              type: integer
                              description: Error code
                            field:
                              type: string
                              description: Name of the field that did not pass validation
                            message:
                              type: string
                              description: Details of the problem
                            rejectedValue:
                              description: The value that did not pass validation
                              anyOf:
                                - type: string
                                - type: number
                                - type: integer
                                - type: boolean
                                - type: array
                                  items: {}
                                - type: object
                      status:
                        type: integer
                        format: int32
                        description: Status code
                      timestamp:
                        type: string
                        description: Time when the message was sent
                      path:
                        type: string
                        description: URL of the requested resource
                      traceId:
                        type: string
                        description: ID for debugging
                  - type: object
                    properties:
                      errorCode:
                        type: string
                        description: |
                          Error code, if applicable.
                            - `SAU-302`: Email confirmation by hash code (activation link) required
                            - `SAU-303`: Email confirmation by PIN code required
        "404":
          description: Profile not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  errors:
                    type: array
                    description: An array of detailed error messages, if applicable
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                          description: Error code
                        field:
                          type: string
                          description: Name of the field that did not pass validation
                        message:
                          type: string
                          description: Details of the problem
                        rejectedValue:
                          description: The value that did not pass validation
                          anyOf:
                            - type: string
                            - type: number
                            - type: integer
                            - type: boolean
                            - type: array
                              items: {}
                            - type: object
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  path:
                    type: string
                    description: URL of the requested resource
                  traceId:
                    type: string
                    description: ID for debugging
              example:
                timestamp: 2018-06-07T07:17:41.734+00:00
                status: 404
                error: Not Found
                message: Account does not exist
                path: /v3/auth/login/client
                traceId: 61b4aa7c0cb1167a
        "406":
          description: Account is locked, password reset required
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  errors:
                    type: array
                    description: An array of detailed error messages, if applicable
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                          description: Error code
                        field:
                          type: string
                          description: Name of the field that did not pass validation
                        message:
                          type: string
                          description: Details of the problem
                        rejectedValue:
                          description: The value that did not pass validation
                          anyOf:
                            - type: string
                            - type: number
                            - type: integer
                            - type: boolean
                            - type: array
                              items: {}
                            - type: object
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  path:
                    type: string
                    description: URL of the requested resource
                  traceId:
                    type: string
                    description: ID for debugging
              example:
                timestamp: 2021-09-15T10:01:16.203120Z
                status: 406
                error: Banned
                message: Log in has been blocked
                path: /v2/auth/login/client
                traceId: 61b4aa7c0cb1167a
        "423":
          description: Device control is enabled, device must be authorized (link sent by email)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Description of the problem
                  errors:
                    type: array
                    description: An array of detailed error messages, if applicable
                    items:
                      type: object
                      properties:
                        code:
                          type: integer
                          description: Error code
                        field:
                          type: string
                          description: Name of the field that did not pass validation
                        message:
                          type: string
                          description: Details of the problem
                        rejectedValue:
                          description: The value that did not pass validation
                          anyOf:
                            - type: string
                            - type: number
                            - type: integer
                            - type: boolean
                            - type: array
                              items: {}
                            - type: object
                  status:
                    type: integer
                    format: int32
                    description: Status code
                  timestamp:
                    type: string
                    description: Time when the message was sent
                  path:
                    type: string
                    description: URL of the requested resource
                  traceId:
                    type: string
                    description: ID for debugging
              example:
                timestamp: 2021-09-15T10:01:16.203120Z
                status: 423
                error: Locked
                message: Device login blocked
                path: /v2/auth/login/client
                traceId: 61b4aa7c0cb1167a
      x-snr-doc-urls:
        - /api-reference/authorization#tag/Authorization-(deprecated)/operation/authenticateViaServerV2
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/sauth/v2/auth/server/login/client \
              --header 'content-type: application/json' \
              --data '{"ipAddress":"string","apiKey":"string","identityProvider":"SYNERISE","identityProviderToken":"string","email":"string","customId":null,"password":"string","uuid":"string","deviceId":"string","agreements":{"email":true,"sms":true,"push":true,"bluetooth":false,"rfid":false,"wifi":false},"attributes":{"property1":null,"property2":null},"tags":["string"]}'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "{\"ipAddress\":\"string\",\"apiKey\":\"string\",\"identityProvider\":\"SYNERISE\",\"identityProviderToken\":\"string\",\"email\":\"string\",\"customId\":null,\"password\":\"string\",\"uuid\":\"string\",\"deviceId\":\"string\",\"agreements\":{\"email\":true,\"sms\":true,\"push\":true,\"bluetooth\":false,\"rfid\":false,\"wifi\":false},\"attributes\":{\"property1\":null,\"property2\":null},\"tags\":[\"string\"]}"

            headers = { 'content-type': "application/json" }

            conn.request("POST", "/sauth/v2/auth/server/login/client", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "ipAddress": "string",
              "apiKey": "string",
              "identityProvider": "SYNERISE",
              "identityProviderToken": "string",
              "email": "string",
              "customId": null,
              "password": "string",
              "uuid": "string",
              "deviceId": "string",
              "agreements": {
                "email": true,
                "sms": true,
                "push": true,
                "bluetooth": false,
                "rfid": false,
                "wifi": false
              },
              "attributes": {
                "property1": null,
                "property2": null
              },
              "tags": [
                "string"
              ]
            });

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/sauth/v2/auth/server/login/client");
            xhr.setRequestHeader("content-type", "application/json");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/sauth/v2/auth/server/login/client",
              "headers": {
                "content-type": "application/json"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              ipAddress: 'string',
              apiKey: 'string',
              identityProvider: 'SYNERISE',
              identityProviderToken: 'string',
              email: 'string',
              customId: null,
              password: 'string',
              uuid: 'string',
              deviceId: 'string',
              agreements: {email: true, sms: true, push: true, bluetooth: false, rfid: false, wifi: false},
              attributes: {property1: null, property2: null},
              tags: ['string']
            }));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/sauth/v2/auth/server/login/client');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'content-type' => 'application/json'
            ]);

            $request->setBody('{"ipAddress":"string","apiKey":"string","identityProvider":"SYNERISE","identityProviderToken":"string","email":"string","customId":null,"password":"string","uuid":"string","deviceId":"string","agreements":{"email":true,"sms":true,"push":true,"bluetooth":false,"rfid":false,"wifi":false},"attributes":{"property1":null,"property2":null},"tags":["string"]}');

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/sauth/v2/auth/server/login/client")
              .header("content-type", "application/json")
              .body("{\"ipAddress\":\"string\",\"apiKey\":\"string\",\"identityProvider\":\"SYNERISE\",\"identityProviderToken\":\"string\",\"email\":\"string\",\"customId\":null,\"password\":\"string\",\"uuid\":\"string\",\"deviceId\":\"string\",\"agreements\":{\"email\":true,\"sms\":true,\"push\":true,\"bluetooth\":false,\"rfid\":false,\"wifi\":false},\"attributes\":{\"property1\":null,\"property2\":null},\"tags\":[\"string\"]}")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Authorization (deprecated)
```
