# Customers Assignments

Manage customer assignments to segments

## Retrieving all customer assignments for a customer segment

> \
> Retrieves all customer assignments for a given customer segment.\
> \### Required scopes\
> \*  \`customersegment.segment\_read\` - allows you to retrieve customer assignments for a customer segment\
> \*  \`customersegment.segment\_read\_own\` - allows customers to retrieve their own assignments to a active customer segment<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"schemas":{"CustomerAssignmentResponse":{"allOf":[{"type":"object","properties":{"legalEntity":{"$ref":"#/components/schemas/LegalEntity"}}},{"$ref":"#/components/schemas/CustomerAssignmentB2CResponse"}]},"LegalEntity":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing legal entity."},"name":{"type":"string","description":"Name of a legal entity."}}},"CustomerAssignmentB2CResponse":{"allOf":[{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/Customer"}}},{"type":"object","properties":{"assignmentType":{"type":"string","enum":["MANUAL","AUTOMATIC"]}}},{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}}]},"Customer":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing customer."},"firstName":{"type":"string","description":"Customer's first name."},"lastName":{"type":"string","description":"Customer's last name."},"email":{"type":"string","description":"Customer's e-mail address."}}},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema.","additionalProperties":true}}},"MetadataResponse":{"allOf":[{"type":"object","properties":{"createdAt":{"description":"The creation date.","type":"string","format":"date-time"},"modifiedAt":{"description":"The modification date.","type":"string","format":"date-time"}}},{"$ref":"#/components/schemas/MetadataUpdate"}]},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"parameters":{"qParam":{"in":"query","name":"q","description":"A standard query parameter is used to search for specific values. \n\nSee: [Standard practises - Query parameter](https://developer.emporix.io/api-references/standard-practices/q-param)\n","schema":{"type":"string"}},"pageSize":{"schema":{"type":"string"},"in":"query","name":"pageSize","description":"The number of documents to be retrieved per page."},"pageNumber":{"schema":{"type":"string"},"in":"query","name":"pageNumber","description":"The page number to be retrieved. The size of the pages should be specified by the pageSize parameter."},"sort":{"schema":{"type":"string"},"in":"query","name":"sort","description":"List of properties used to sort the results, separated by colons."},"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."},"xTotalCount":{"schema":{"type":"boolean"},"in":"header","name":"X-Total-Count","description":"Flag indicating whether the total number of retrieved results should be returned."}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers":{"get":{"summary":"Retrieving all customer assignments for a customer segment","tags":["Customers Assignments"],"description":"\nRetrieves all customer assignments for a given customer segment.\n### Required scopes\n*  `customersegment.segment_read` - allows you to retrieve customer assignments for a customer segment\n*  `customersegment.segment_read_own` - allows customers to retrieve their own assignments to a active customer segment\n","responses":{"200":{"description":"Customer assignments for a customer segment were successfully retrieved.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CustomerAssignmentResponse"}}}}},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}},"operationId":"GET-customer-segment-retrieve-customers","parameters":[{"$ref":"#/components/parameters/qParam"},{"$ref":"#/components/parameters/pageSize"},{"$ref":"#/components/parameters/pageNumber"},{"$ref":"#/components/parameters/sort"},{"$ref":"#/components/parameters/fields"},{"$ref":"#/components/parameters/xTotalCount"}]}}}}
```

## Searching with parameters for customer assignments

> \
> Returns all customer assignments that match provided criteria.\
> \### Required scopes\
> \*  \`customersegment.segment\_read\` - allows you to retrieve customer assignments for a customer segment<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"schemas":{"SegmentsSearch":{"type":"object","properties":{"q":{"type":"string","description":"A standard query parameter is used to search for specific values. \n\nSee: [Standard practises - Query parameter](https://developer.emporix.io/api-references/standard-practices/q-param/)\n"}}},"CustomerAssignmentResponse":{"allOf":[{"type":"object","properties":{"legalEntity":{"$ref":"#/components/schemas/LegalEntity"}}},{"$ref":"#/components/schemas/CustomerAssignmentB2CResponse"}]},"LegalEntity":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing legal entity."},"name":{"type":"string","description":"Name of a legal entity."}}},"CustomerAssignmentB2CResponse":{"allOf":[{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/Customer"}}},{"type":"object","properties":{"assignmentType":{"type":"string","enum":["MANUAL","AUTOMATIC"]}}},{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}}]},"Customer":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing customer."},"firstName":{"type":"string","description":"Customer's first name."},"lastName":{"type":"string","description":"Customer's last name."},"email":{"type":"string","description":"Customer's e-mail address."}}},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema.","additionalProperties":true}}},"MetadataResponse":{"allOf":[{"type":"object","properties":{"createdAt":{"description":"The creation date.","type":"string","format":"date-time"},"modifiedAt":{"description":"The modification date.","type":"string","format":"date-time"}}},{"$ref":"#/components/schemas/MetadataUpdate"}]},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"parameters":{"pageSize":{"schema":{"type":"string"},"in":"query","name":"pageSize","description":"The number of documents to be retrieved per page."},"pageNumber":{"schema":{"type":"string"},"in":"query","name":"pageNumber","description":"The page number to be retrieved. The size of the pages should be specified by the pageSize parameter."},"sort":{"schema":{"type":"string"},"in":"query","name":"sort","description":"List of properties used to sort the results, separated by colons."},"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."},"xTotalCount":{"schema":{"type":"boolean"},"in":"header","name":"X-Total-Count","description":"Flag indicating whether the total number of retrieved results should be returned."}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/search":{"post":{"summary":"Searching with parameters for customer assignments","tags":["Customers Assignments"],"description":"\nReturns all customer assignments that match provided criteria.\n### Required scopes\n*  `customersegment.segment_read` - allows you to retrieve customer assignments for a customer segment\n","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SegmentsSearch"}}}},"responses":{"200":{"description":"Customer assignments for a customer segment were successfully retrieved.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CustomerAssignmentResponse"}}}}},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}},"operationId":"POST-customer-segment-search-customers","parameters":[{"$ref":"#/components/parameters/pageSize"},{"$ref":"#/components/parameters/pageNumber"},{"$ref":"#/components/parameters/sort"},{"$ref":"#/components/parameters/fields"},{"$ref":"#/components/parameters/xTotalCount"}]}}}}
```

## \[B2C] Retrieving a customer assignment for a customer segment

> \
> Retrieves a customer with specified customerId assigned to a customer segment.\
> \### Required scopes\
> \*  \`customersegment.segment\_read\` - allows you to retrieve a customer assignment for a active customer segment<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"schemas":{"CustomerAssignmentB2CResponse":{"allOf":[{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/Customer"}}},{"type":"object","properties":{"assignmentType":{"type":"string","enum":["MANUAL","AUTOMATIC"]}}},{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}}]},"Customer":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing customer."},"firstName":{"type":"string","description":"Customer's first name."},"lastName":{"type":"string","description":"Customer's last name."},"email":{"type":"string","description":"Customer's e-mail address."}}},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema.","additionalProperties":true}}},"MetadataResponse":{"allOf":[{"type":"object","properties":{"createdAt":{"description":"The creation date.","type":"string","format":"date-time"},"modifiedAt":{"description":"The modification date.","type":"string","format":"date-time"}}},{"$ref":"#/components/schemas/MetadataUpdate"}]},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_NotFound_404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"parameters":{"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}":{"get":{"summary":"[B2C] Retrieving a customer assignment for a customer segment","tags":["Customers Assignments"],"description":"\nRetrieves a customer with specified customerId assigned to a customer segment.\n### Required scopes\n*  `customersegment.segment_read` - allows you to retrieve a customer assignment for a active customer segment\n","responses":{"200":{"description":"Customer assignment for a customer segment was successfully retrieved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerAssignmentB2CResponse"}}}},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"},"404":{"$ref":"#/components/responses/Common_response_NotFound_404"}},"operationId":"GET-customer-segment-retrieve-customer-by-customerId","parameters":[{"$ref":"#/components/parameters/fields"}]}}}}
```

## \[B2C] Updating a customer assignment for a customer segment

> \
> Performs \`UPSERT\` operation. Updates a customer assigned to a customer segment. A new customer assignment is created if it's not present in the system.\
> \### Required scopes\
> \*  \`customersegment.segment\_manage\` - required to add and modify customer assignments<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"schemas":{"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema.","additionalProperties":true}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Conflict_409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}":{"put":{"summary":"[B2C] Updating a customer assignment for a customer segment","tags":["Customers Assignments"],"operationId":"PUT-customer-segment-update-customer-by-customerId","description":"\nPerforms `UPSERT` operation. Updates a customer assigned to a customer segment. A new customer assignment is created if it's not present in the system.\n### Required scopes\n*  `customersegment.segment_manage` - required to add and modify customer assignments\n","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerAssignmentUpsert"}}}},"responses":{"201":{"description":"A new customer assignment was successfully created."},"204":{"description":"Customer assignment was successfully updated."},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"},"409":{"$ref":"#/components/responses/Common_response_Conflict_409"}}}}}}
```

## \[B2C] Removing a customer from customer segment

> \
> Removes customer assignment.\
> \### Required scopes\
> \*  \`customersegment.segment\_manage\` - required to delete customer assignments<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}":{"delete":{"summary":"[B2C] Removing a customer from customer segment","tags":["Customers Assignments"],"operationId":"DELETE-customer-segment-remove-customer-by-customerId","description":"\nRemoves customer assignment.\n### Required scopes\n*  `customersegment.segment_manage` - required to delete customer assignments\n","responses":{"204":{"description":"Customer assignment was successfully removed."},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}}}}}}
```

## \[B2B] Retrieving a customer assignment for a customer segment

> \
> Retrieves a customer with specified customerId and companyId assigned to a customer segment.\
> \### Required scopes\
> \*  \`customersegment.segment\_read\` - allows you to retrieve a customer assignment for a customer segment<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"schemas":{"CustomerAssignmentResponse":{"allOf":[{"type":"object","properties":{"legalEntity":{"$ref":"#/components/schemas/LegalEntity"}}},{"$ref":"#/components/schemas/CustomerAssignmentB2CResponse"}]},"LegalEntity":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing legal entity."},"name":{"type":"string","description":"Name of a legal entity."}}},"CustomerAssignmentB2CResponse":{"allOf":[{"type":"object","properties":{"customer":{"$ref":"#/components/schemas/Customer"}}},{"type":"object","properties":{"assignmentType":{"type":"string","enum":["MANUAL","AUTOMATIC"]}}},{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/MetadataResponse"}}}]},"Customer":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier of an existing customer."},"firstName":{"type":"string","description":"Customer's first name."},"lastName":{"type":"string","description":"Customer's last name."},"email":{"type":"string","description":"Customer's e-mail address."}}},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema.","additionalProperties":true}}},"MetadataResponse":{"allOf":[{"type":"object","properties":{"createdAt":{"description":"The creation date.","type":"string","format":"date-time"},"modifiedAt":{"description":"The modification date.","type":"string","format":"date-time"}}},{"$ref":"#/components/schemas/MetadataUpdate"}]},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_NotFound_404":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"parameters":{"fields":{"schema":{"type":"string"},"in":"query","name":"fields","description":"Fields to be returned in the response."}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}/{legalEntityId}":{"get":{"summary":"[B2B] Retrieving a customer assignment for a customer segment","tags":["Customers Assignments"],"description":"\nRetrieves a customer with specified customerId and companyId assigned to a customer segment.\n### Required scopes\n*  `customersegment.segment_read` - allows you to retrieve a customer assignment for a customer segment\n","responses":{"200":{"description":"Customer assignment for a customer segment was successfully retrieved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerAssignmentResponse"}}}},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"},"404":{"$ref":"#/components/responses/Common_response_NotFound_404"}},"operationId":"GET-customer-segment-retrieve-customer","parameters":[{"$ref":"#/components/parameters/fields"}]}}}}
```

## \[B2B] Updating a customer assignment for a customer segment

> \
> Performs \`UPSERT\` operation. Updates a customer assigned to a customer segment. A new customer assignment is created if it's not present in the system.\
> \### Required scopes\
> \*  \`customersegment.segment\_manage\` - required to add and modify customer assignments<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"schemas":{"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema.","additionalProperties":true}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Conflict_409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}/{legalEntityId}":{"put":{"summary":"[B2B] Updating a customer assignment for a customer segment","tags":["Customers Assignments"],"operationId":"PUT-customer-segment-update-customer","description":"\nPerforms `UPSERT` operation. Updates a customer assigned to a customer segment. A new customer assignment is created if it's not present in the system.\n### Required scopes\n*  `customersegment.segment_manage` - required to add and modify customer assignments\n","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerAssignmentUpsert"}}}},"responses":{"201":{"description":"A new customer assignment was successfully created."},"204":{"description":"Customer assignment was successfully updated."},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"},"409":{"$ref":"#/components/responses/Common_response_Conflict_409"}}}}}}
```

## \[B2B] Removing a customer from customer segment

> \
> Removes customer assignment.\
> \### Required scopes\
> \*  \`customersegment.segment\_manage\` - required to delete customer assignments<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"responses":{"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/{customerId}/{legalEntityId}":{"delete":{"summary":"[B2B] Removing a customer from customer segment","tags":["Customers Assignments"],"operationId":"DELETE-customer-segment-remove-customer","description":"\nRemoves customer assignment.\n### Required scopes\n*  `customersegment.segment_manage` - required to delete customer assignments\n","responses":{"204":{"description":"Customer assignment was successfully removed."},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}}}}}}
```

## Updating customer assignments for a customer segment in bulk

> \
> Performs \`UPSERT\` operation. Updates multiple customer assignments to a customer segment. The maximum batch size is 200.\
> \
> \### Required scopes\
> \*  \`customersegment.segment\_manage\` - required to add and modify customer assignments<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"schemas":{"CustomerAssignmentUpsertBulk":{"allOf":[{"$ref":"#/components/schemas/CustomerAssignmentUpsert"},{"type":"object","properties":{"customerId":{"type":"string","description":"Unique identifier of an existing customer."},"legalEntityId":{"type":"string","description":"Unique identifier of an existing legal entity. It should be omitted for B2C."}}}]},"CustomerAssignmentUpsert":{"type":"object","description":"","properties":{"mixins":{"type":"object","description":"A key-value map of additional attributes.","additionalProperties":true},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}}},"MetadataUpdate":{"allOf":[{"type":"object","properties":{"version":{"type":"integer","description":"The document version number."}}},{"$ref":"#/components/schemas/MetadataCreate"}]},"MetadataCreate":{"type":"object","properties":{"mixins":{"type":"object","description":"A key-value map, where key is a mixin name and value is a link to the mixin schema.","additionalProperties":true}}},"BulkAssignmentResponse":{"type":"object","properties":{"index":{"type":"integer","description":"Index of the processed item, matching the item position in request body.\n"},"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status description."},"message":{"type":"string","description":"Error message."}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/bulk":{"put":{"summary":"Updating customer assignments for a customer segment in bulk","tags":["Customers Assignments"],"operationId":"PUT-customer-segment-update-customers-bulk","description":"\nPerforms `UPSERT` operation. Updates multiple customer assignments to a customer segment. The maximum batch size is 200.\n\n### Required scopes\n*  `customersegment.segment_manage` - required to add and modify customer assignments\n","requestBody":{"content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CustomerAssignmentUpsertBulk"}}}}},"responses":{"207":{"description":"Multi-status response.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/BulkAssignmentResponse"}}}}},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}}}}}}
```

## Removing customers from customer segment in bulk

> \
> Removes multiple customer assignments to a customer segment. The maximum batch size is 200.\
> \
> \### The request body for this endpoint is array of objects with \`customerId\` and \`legalEntityId\` fields.\
> \#### Example: \`\[{"customerId": "firstCustomerId", "legalEntityId": "firstLegalEntityId"}, {"customerId": "secondCustomerId", "legalEntityId": "secondLegalEntityId"}, {"customerId": "thirdCustomerId", "legalEntityId": "thirdLegalEntityId"}]\`\
> \### Required scopes\
> \*  \`customersegment.segment\_manage\` - required to delete customer assignments<br>

```json
{"openapi":"3.0.0","info":{"title":"Customer Segment Service","version":"0.0.1"},"tags":[{"name":"Customers Assignments","description":"Manage customer assignments to segments"}],"servers":[{"url":"https://api.emporix.io"}],"security":[{"OAuth2":[]}],"components":{"securitySchemes":{"OAuth2":{"type":"oauth2","flows":{"clientCredentials":{"tokenUrl":"https://api.emporix.io/oauth/token","scopes":{"customersegment.segment_manage":"Needed to create or update customer segments.","customersegment.segment_read":"Needed to read customer segments.","customersegment.segment_read_own":"Needed to read own customer segments."}}}}},"schemas":{"BulkAssignmentResponse":{"type":"object","properties":{"index":{"type":"integer","description":"Index of the processed item, matching the item position in request body.\n"},"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status description."},"message":{"type":"string","description":"Error message."}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code."},"status":{"type":"string","description":"HTTP Status."},"message":{"type":"string","description":"Error message."},"resourceId":{"type":"string","description":"An ID of the resource which caused the error."},"details":{"type":"object","description":"Error details","properties":{"field":{"type":"string"},"type":{"type":"string"},"message":{"type":"string"},"moreInfo":{"type":"string"}}}}}},"responses":{"Common_response_BadRequest_400":{"description":"Bad request due to validation, incorrect parameters, etc.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"Common_response_Unauthorized_401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"fault":{"type":"object","properties":{"faultstring":{"type":"string"},"detail":{"type":"object","properties":{"errorcode":{"type":"string"}}}}}}}}}},"Common_response_Forbidden_403":{"description":"Access forbidden. The caller is not allowed to access this resource.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"paths":{"/customer-segment/{tenant}/segments/{segmentId}/customers/bulk":{"delete":{"summary":"Removing customers from customer segment in bulk","tags":["Customers Assignments"],"operationId":"DELETE-customer-segment-remove-customers-bulk","description":"\nRemoves multiple customer assignments to a customer segment. The maximum batch size is 200.\n\n### The request body for this endpoint is array of objects with `customerId` and `legalEntityId` fields.\n#### Example: `[{\"customerId\": \"firstCustomerId\", \"legalEntityId\": \"firstLegalEntityId\"}, {\"customerId\": \"secondCustomerId\", \"legalEntityId\": \"secondLegalEntityId\"}, {\"customerId\": \"thirdCustomerId\", \"legalEntityId\": \"thirdLegalEntityId\"}]`\n### Required scopes\n*  `customersegment.segment_manage` - required to delete customer assignments\n","responses":{"207":{"description":"Multi-status response.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/BulkAssignmentResponse"}}}}},"400":{"$ref":"#/components/responses/Common_response_BadRequest_400"},"401":{"$ref":"#/components/responses/Common_response_Unauthorized_401"},"403":{"$ref":"#/components/responses/Common_response_Forbidden_403"}}}}}}
```
