# Models

## The ContextAttribute object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"ContextAttribute":{"title":"ContextAttribute","description":"Context attribute","type":"object","properties":{"key":{"type":"string","description":"Additional context information key"},"value":{"description":"Additional context information value","oneOf":[{"type":"object"},{"type":"string"}]}},"required":["key","value"]}}}}
```

## The SessionContext\_GET object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"SessionContext_GET":{"allOf":[{"$ref":"#/components/schemas/SessionContextBase"},{"type":"object","properties":{"context":{"$ref":"#/components/schemas/Context"}}},{"type":"object","properties":{"metadata":{"$ref":"#/components/schemas/Metadata"}}}]},"SessionContextBase":{"title":"SessionContextBase","type":"object","properties":{"sessionId":{"type":"string","description":"Unique identifier of the customer's session."},"customerId":{"type":"string","description":"Customer unique identifier.\n\n**Note**: This field is only applicable to logged-in customers."},"siteCode":{"type":"string","description":"Code of the site, as defined in the Site Settings Service.\n\n**Note**: The default country code for anonymous sessions is based on the home base address country of the default site. In the case of a logged-in customer session, the country code is derived from the customer's shipping address, with the billing address being used as a fallback if the former is not available. If both addresses are not set, the home base address country code from the default site is used."},"currency":{"type":"string","description":"Three-letter currency code, as defined in the Currency Service.\n\n**Note**: During an anonymous session, the default currency of the site serves as the initial currency. Whereas, for a user session, the customer's preferred currency is set as the initial currency."},"cartId":{"type":"string","description":"Unique identifier of the active customer cart, generated when the cart is created through the Cart Service."},"targetLocation":{"type":"string","description":"The country code, as defined in the country service.\n\n\n**Note**: The default country code for anonymous sessions is based on the home base address country of the default site. In the case of a logged-in customer session, the country code is derived from the customer's shipping address, with the billing address being used as a fallback if the former is not available. If both addresses are not set, the home base address country code from the default site is used."}}},"Context":{"title":"Context","type":"object","additionalProperties":{"type":"object"}},"Metadata":{"allOf":[{"$ref":"#/components/schemas/MetadataUpdate"},{"type":"object","properties":{"createdAt":{"type":"string","description":"Date and time when the object was created."},"modifiedAt":{"type":"string","description":"Date and time when the object was last modified."}}}]},"MetadataUpdate":{"title":"Metadata","type":"object","properties":{"version":{"type":"integer","description":"Version of the session context object."}}}}}}
```

## The SessionContext\_PUT object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"SessionContext_PUT":{"title":"SessionContextUpdateRequest","description":"Request body for updating a session context (PUT).\nYou can send any of the session fields returned in the GET response, including `context` (custom attributes key-value map).\nThe `metadata.version` is required for optimistic locking.\n","allOf":[{"$ref":"#/components/schemas/SessionContextBase"},{"type":"object","properties":{"context":{"$ref":"#/components/schemas/Context","description":"Custom session attributes. Same structure as returned in the response."},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}},"required":["metadata"]}]},"SessionContextBase":{"title":"SessionContextBase","type":"object","properties":{"sessionId":{"type":"string","description":"Unique identifier of the customer's session."},"customerId":{"type":"string","description":"Customer unique identifier.\n\n**Note**: This field is only applicable to logged-in customers."},"siteCode":{"type":"string","description":"Code of the site, as defined in the Site Settings Service.\n\n**Note**: The default country code for anonymous sessions is based on the home base address country of the default site. In the case of a logged-in customer session, the country code is derived from the customer's shipping address, with the billing address being used as a fallback if the former is not available. If both addresses are not set, the home base address country code from the default site is used."},"currency":{"type":"string","description":"Three-letter currency code, as defined in the Currency Service.\n\n**Note**: During an anonymous session, the default currency of the site serves as the initial currency. Whereas, for a user session, the customer's preferred currency is set as the initial currency."},"cartId":{"type":"string","description":"Unique identifier of the active customer cart, generated when the cart is created through the Cart Service."},"targetLocation":{"type":"string","description":"The country code, as defined in the country service.\n\n\n**Note**: The default country code for anonymous sessions is based on the home base address country of the default site. In the case of a logged-in customer session, the country code is derived from the customer's shipping address, with the billing address being used as a fallback if the former is not available. If both addresses are not set, the home base address country code from the default site is used."}}},"Context":{"title":"Context","type":"object","additionalProperties":{"type":"object"}},"MetadataUpdate":{"title":"Metadata","type":"object","properties":{"version":{"type":"integer","description":"Version of the session context object."}}}}}}
```

## The SessionContext\_PATCH object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"SessionContext_PATCH":{"title":"SessionContextPartialUpdateRequest","description":"Request body for partially updating own session context (PATCH /me/context).\nOnly the following fields can be updated; all other fields are ignored.\n","type":"object","properties":{"siteCode":{"type":"string","description":"Code of the site, as defined in the Site Settings Service."},"currency":{"type":"string","description":"Three-letter currency code, as defined in the Currency Service."},"targetLocation":{"type":"string","description":"The country code, as defined in the country service."},"context":{"$ref":"#/components/schemas/Context","description":"Custom session attributes. Same structure as returned in the response."},"metadata":{"$ref":"#/components/schemas/MetadataUpdate"}},"required":["metadata"]},"Context":{"title":"Context","type":"object","additionalProperties":{"type":"object"}},"MetadataUpdate":{"title":"Metadata","type":"object","properties":{"version":{"type":"integer","description":"Version of the session context object."}}}}}}
```

## The ErrorMessage object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"ErrorMessage":{"type":"object","properties":{"code":{"type":"integer","description":"HTTP Status Code"},"message":{"type":"string","description":"Detailed error message"}}}}}}
```

## The SessionContextBase object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"SessionContextBase":{"title":"SessionContextBase","type":"object","properties":{"sessionId":{"type":"string","description":"Unique identifier of the customer's session."},"customerId":{"type":"string","description":"Customer unique identifier.\n\n**Note**: This field is only applicable to logged-in customers."},"siteCode":{"type":"string","description":"Code of the site, as defined in the Site Settings Service.\n\n**Note**: The default country code for anonymous sessions is based on the home base address country of the default site. In the case of a logged-in customer session, the country code is derived from the customer's shipping address, with the billing address being used as a fallback if the former is not available. If both addresses are not set, the home base address country code from the default site is used."},"currency":{"type":"string","description":"Three-letter currency code, as defined in the Currency Service.\n\n**Note**: During an anonymous session, the default currency of the site serves as the initial currency. Whereas, for a user session, the customer's preferred currency is set as the initial currency."},"cartId":{"type":"string","description":"Unique identifier of the active customer cart, generated when the cart is created through the Cart Service."},"targetLocation":{"type":"string","description":"The country code, as defined in the country service.\n\n\n**Note**: The default country code for anonymous sessions is based on the home base address country of the default site. In the case of a logged-in customer session, the country code is derived from the customer's shipping address, with the billing address being used as a fallback if the former is not available. If both addresses are not set, the home base address country code from the default site is used."}}}}}}
```

## The MetadataUpdate object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"MetadataUpdate":{"title":"Metadata","type":"object","properties":{"version":{"type":"integer","description":"Version of the session context object."}}}}}}
```

## The Metadata object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"Metadata":{"allOf":[{"$ref":"#/components/schemas/MetadataUpdate"},{"type":"object","properties":{"createdAt":{"type":"string","description":"Date and time when the object was created."},"modifiedAt":{"type":"string","description":"Date and time when the object was last modified."}}}]},"MetadataUpdate":{"title":"Metadata","type":"object","properties":{"version":{"type":"integer","description":"Version of the session context object."}}}}}}
```

## The Context object

```json
{"openapi":"3.0.0","info":{"title":"Session Context Service","version":"0.0.1"},"components":{"schemas":{"Context":{"title":"Context","type":"object","additionalProperties":{"type":"object"}}}}}
```
