# Customer API overview

> Base URLs, versioning, authentication and the customer creation endpoints of the Segmentify Customer API.

| Item | Value |
| --- | --- |
| API title | Segmentify Customer API |
| API version | `1.0` |
| Protocol | HTTPS / REST, JSON payloads |
| Auth scheme | OAuth2 Bearer token (`Authorization: Bearer` ) |

## Base URL

The service is deployed per environment.

```
Türkiye -> https://api-eq.segmentify.com
Global -> https://api-gcp.segmentify.com

 ```

## API version header

Every endpoint is versioned. Send the API version as a request header:

```
X-Api-Version: 1.0

 ```

## Content type

All request and response bodies are JSON:

```
Content-Type: application/json
Accept: application/json

 ```

## Authentication model

- The **authentication endpoints** under `/auth` are public — they do **not** require a Bearer token (they are how you obtain one).

- All **customer endpoints** under `/customer` require a valid Bearer access token.

## Authentication flow

Obtain an access token with your credentials, then send it as a Bearer token on every customer request. Access tokens are short-lived; use the refresh endpoint to get a new pair without re-sending credentials.

## Login

`POST /auth/token`

Exchanges a username and password for an access token and a refresh token.

**Request**

```json
{
  "username": "acme-integration",
  "password": "s3cr3t-p@ssw0rd"
}
```

**Response** (200)

```json
{
  "accessToken": "ACCESS_TOKEN",
  "refreshToken": "REFRESH_TOKEN",
  "accessExpiresInTime": 900,
  "refreshExpiresInTime": 2592000
}
```

## Refresh Token

`POST /auth/token/refresh`

Exchanges a valid refresh token for a **new** access/refresh token pair. Call this before the access token expires (or after receiving a `401`) to avoid re-sending credentials.

**Request**

```json
{
  "refreshToken": "REFRESH_TOKEN"
}
```

**Response** (200)

```json
{
  "accessToken": "ACCESS_TOKEN",
  "refreshToken": "REFRESH_TOKEN",
  "accessExpiresInTime": 900,
  "refreshExpiresInTime": 2592000
}
```

## Single Customer

`POST /customer/`

Creates (or resolves and updates) a single customer and returns the resulting customer profile.

**Request**

```json
{
  "firstName": "Jane",
  "lastName": "Doe",
  "email": "jane.doe@example.com",
  "phone": "+905055554433",
  "gender": "FEMALE",
  "birthDate": "1990-05-14",
  "maritalStatus": "SINGLE",
  "country": "Turkey",
  "city": "Istanbul",
  "district": "Kadikoy",
  "postalCode": "34000",
  "language": "tr",
  "currency": "TRY",
  "region": "TR-34",
  "timeZone": "Europe/Istanbul",
  "creationSource": "API",
  "membershipDate": "2026-01-15T10:30:00+03:00",
  "loginMethods": [
    "email",
    "google"
  ],
  "custom": {
    "loyaltyId": "LYT-99123",
    "segment": "vip"
  },
  "channelConsents": {
    "EMAIL": {
      "marketing": {
        "state": "SUBSCRIBED"
      },
      "transactional": {
        "state": "SUBSCRIBED"
      }
    }
  }
}
```

**Response** (200)

```json
{
  "id": "9b2e6c1a-3f4d-4a2b-8c7e-1f2a3b4c5d6e",
  "firstName": "Jane",
  "lastName": "Doe",
  "email": "jane.doe@example.com",
  "customAttributes": {},
  "customIdentifiers": {},
  "createdAt": 1767181800000,
  "changeType": "CREATED"
}
```

## Batch Customers

`POST /customer/batch`

Creates customers in bulk. Supports **partial success**: the request is validated per record, then valid records are processed and reported as succeeded/failed. Invalid records are reported separately and never processed.

**Request**

```json
[
  {
    "firstName": "Jane",
    "lastName": "Doe",
    "email": "jane.doe@example.com",
    "phone": "+905055554433",
    "gender": "FEMALE",
    "birthDate": "1990-05-14",
    "maritalStatus": "SINGLE",
    "country": "Turkey",
    "city": "Istanbul",
    "district": "Kadikoy",
    "postalCode": "34000",
    "language": "tr",
    "currency": "TRY",
    "region": "TR-34",
    "timeZone": "Europe/Istanbul",
    "creationSource": "API",
    "membershipDate": "2026-01-15T10:30:00+03:00",
    "loginMethods": [
      "email",
      "google"
    ],
    "custom": {
      "loyaltyId": "LYT-99123",
      "segment": "vip"
    },
    "channelConsents": {
      "EMAIL": {
        "marketing": {
          "state": "SUBSCRIBED"
        },
        "transactional": {
          "state": "SUBSCRIBED"
        }
      }
    }
  }
]
```

**Response** (200)

```json
{
  "validCount": 2,
  "invalids": [],
  "successCount": 1,
  "fails": [
    {
      "phone": "+905055554433",
      "firstName": "John"
    }
  ]
}
```

## API reference

Send these requests from the [Customer API reference](/reference/customer-api/).
