{
  "openapi": "3.1.0",
  "info": {
    "title": "Segmentify Customer API",
    "version": "1.0",
    "description": "Create customers in Segmentify one at a time or in bulk.\n\n| Item | Value |\n| --- | --- |\n| API title | Segmentify Customer API |\n| API version | `1.0` |\n| Protocol | HTTPS / REST, JSON payloads |\n| Auth scheme | OAuth2 Bearer token (`Authorization: Bearer` ) |"
  },
  "servers": [
    {
      "url": "https://api-eq.segmentify.com",
      "description": "Türkiye"
    },
    {
      "url": "https://api-gcp.segmentify.com",
      "description": "Global"
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "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."
    },
    {
      "name": "Customer Creation"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/auth/token": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "operationId": "login",
        "summary": "Login",
        "security": [],
        "description": "Exchanges a username and password for an access token and a refresh token.",
        "parameters": [
          {
            "name": "X-Api-Version",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "default": "1.0"
            },
            "description": "API version."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "username",
                  "password"
                ],
                "properties": {
                  "username": {
                    "type": "string",
                    "description": "Account username"
                  },
                  "password": {
                    "type": "string",
                    "description": "Account password",
                    "format": "password"
                  }
                }
              },
              "example": {
                "username": "acme-integration",
                "password": "s3cr3t-p@ssw0rd"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token pair.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenPair"
                },
                "example": {
                  "accessToken": "ACCESS_TOKEN",
                  "refreshToken": "REFRESH_TOKEN",
                  "accessExpiresInTime": 900,
                  "refreshExpiresInTime": 2592000
                }
              }
            }
          }
        }
      }
    },
    "/auth/token/refresh": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "operationId": "refreshToken",
        "summary": "Refresh token",
        "security": [],
        "description": "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.",
        "parameters": [
          {
            "name": "X-Api-Version",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "default": "1.0"
            },
            "description": "API version."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "refreshToken"
                ],
                "properties": {
                  "refreshToken": {
                    "type": "string",
                    "description": "Valid refresh token"
                  }
                }
              },
              "example": {
                "refreshToken": "REFRESH_TOKEN"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "New token pair.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenPair"
                },
                "example": {
                  "accessToken": "ACCESS_TOKEN",
                  "refreshToken": "REFRESH_TOKEN",
                  "accessExpiresInTime": 900,
                  "refreshExpiresInTime": 2592000
                }
              }
            }
          }
        }
      }
    },
    "/customer/": {
      "post": {
        "tags": [
          "Customer Creation"
        ],
        "operationId": "createCustomer",
        "summary": "Single customer",
        "description": "Creates (or resolves and updates) a single customer and returns the resulting customer profile.",
        "parameters": [
          {
            "name": "X-Api-Version",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "default": "1.0"
            },
            "description": "API version."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Customer"
              },
              "example": {
                "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"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The resulting customer profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerResult"
                },
                "example": {
                  "id": "9b2e6c1a-3f4d-4a2b-8c7e-1f2a3b4c5d6e",
                  "firstName": "Jane",
                  "lastName": "Doe",
                  "email": "jane.doe@example.com",
                  "customAttributes": {},
                  "customIdentifiers": {},
                  "createdAt": 1767181800000,
                  "changeType": "CREATED"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired access token. Get a new token pair with the refresh endpoint."
          }
        }
      }
    },
    "/customer/batch": {
      "post": {
        "tags": [
          "Customer Creation"
        ],
        "operationId": "createCustomersBatch",
        "summary": "Batch customers",
        "description": "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.",
        "parameters": [
          {
            "name": "X-Api-Version",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "default": "1.0"
            },
            "description": "API version."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Customer"
                }
              },
              "example": [
                {
                  "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"
                      }
                    }
                  }
                }
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Per-record result of the batch.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchResult"
                },
                "example": {
                  "validCount": 2,
                  "invalids": [],
                  "successCount": 1,
                  "fails": [
                    {
                      "phone": "+905055554433",
                      "firstName": "John"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or expired access token. Get a new token pair with the refresh endpoint."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Access token returned by `POST /auth/token`."
      }
    },
    "schemas": {
      "TokenPair": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "refreshToken": {
            "type": "string"
          },
          "accessExpiresInTime": {
            "type": "integer",
            "description": "Access token lifetime in seconds."
          },
          "refreshExpiresInTime": {
            "type": "integer",
            "description": "Refresh token lifetime in seconds."
          }
        }
      },
      "Customer": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "examples": [
              "+905055554433"
            ]
          },
          "gender": {
            "type": "string",
            "examples": [
              "FEMALE"
            ]
          },
          "birthDate": {
            "type": "string",
            "format": "date"
          },
          "maritalStatus": {
            "type": "string",
            "examples": [
              "SINGLE"
            ]
          },
          "country": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "district": {
            "type": "string"
          },
          "postalCode": {
            "type": "string"
          },
          "language": {
            "type": "string",
            "examples": [
              "tr"
            ]
          },
          "currency": {
            "type": "string",
            "examples": [
              "TRY"
            ]
          },
          "region": {
            "type": "string",
            "examples": [
              "TR-34"
            ]
          },
          "timeZone": {
            "type": "string",
            "examples": [
              "Europe/Istanbul"
            ]
          },
          "creationSource": {
            "type": "string",
            "examples": [
              "API"
            ]
          },
          "membershipDate": {
            "type": "string",
            "format": "date-time"
          },
          "loginMethods": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "custom": {
            "type": "object",
            "additionalProperties": true,
            "description": "Custom attributes."
          },
          "channelConsents": {
            "type": "object",
            "additionalProperties": true,
            "description": "Consent state per channel and purpose, for example `EMAIL.marketing.state = \"SUBSCRIBED\"`."
          }
        }
      },
      "CustomerResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "firstName": {
            "type": "string"
          },
          "lastName": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "customAttributes": {
            "type": "object",
            "additionalProperties": true
          },
          "customIdentifiers": {
            "type": "object",
            "additionalProperties": true
          },
          "createdAt": {
            "type": "integer",
            "description": "Unix time in milliseconds."
          },
          "changeType": {
            "type": "string",
            "examples": [
              "CREATED"
            ]
          }
        }
      },
      "BatchResult": {
        "type": "object",
        "properties": {
          "validCount": {
            "type": "integer"
          },
          "invalids": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "successCount": {
            "type": "integer"
          },
          "fails": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      }
    }
  }
}