{
  "components": {
    "examples": {
      "standard-error-400": {
        "description": "The request body or parameters are invalid.",
        "summary": "Bad Request",
        "value": {
          "errors": [],
          "localizedMessage": "Invalid request",
          "message": "Invalid request",
          "status": "BAD_REQUEST",
          "statusCode": 400
        }
      },
      "standard-error-401": {
        "description": "The credentials are missing or invalid, the calling IP is not on the client's allowlist, or mTLS is enforced and no valid client certificate was sent. An expired session token gets 401 Token expired.",
        "summary": "Unauthorized",
        "value": {
          "errors": [],
          "localizedMessage": "Authentication failed",
          "message": "Authentication failed",
          "status": "UNAUTHORIZED",
          "statusCode": 401
        }
      },
      "standard-error-403": {
        "description": "The client is not allowed to use this endpoint or resource.",
        "summary": "Forbidden",
        "value": {
          "errors": [],
          "localizedMessage": "Not allowed",
          "message": "Not allowed",
          "status": "FORBIDDEN",
          "statusCode": 403
        }
      },
      "standard-error-404": {
        "description": "The requested resource does not exist or has expired.",
        "summary": "Not Found",
        "value": {
          "errors": [],
          "localizedMessage": "Not found",
          "message": "Not found",
          "status": "NOT_FOUND",
          "statusCode": 404
        }
      },
      "standard-error-429": {
        "description": "The client has sent too many requests in a given time window. Retry after a delay using exponential backoff.",
        "summary": "Rate limit exceeded",
        "value": {
          "errors": [],
          "localizedMessage": "Too many requests. Please retry with backoff.",
          "message": "Too many requests. Please retry with backoff.",
          "status": "TOO_MANY_REQUESTS",
          "statusCode": 429
        }
      }
    },
    "schemas": {
      "CollectionEntry": {
        "description": "A collection entry contains the collection Id and the creation date of the collection.\n",
        "properties": {
          "collectionId": {
            "description": "The collection Id.",
            "example": "ffb1c7de360e433c8a068a5b87bd4797",
            "type": "string"
          },
          "creationDate": {
            "description": "Timestamp the collection was created at.",
            "example": "2023-10-19T14:05:00.73636Z",
            "format": "date-time",
            "type": "string"
          }
        },
        "title": "Collection Entry"
      },
      "CollectionExportResponse": {
        "properties": {
          "collections": {
            "description": "List containing information about exported collections",
            "items": {
              "$ref": "#/components/schemas/ExportedCollection"
            },
            "type": "array"
          },
          "currentPage": {
            "description": "The page you are currently exporting data for",
            "example": 1,
            "format": "int32",
            "type": "integer"
          },
          "totalPages": {
            "description": "The total amount of pages available to export data for",
            "example": 2,
            "format": "int32",
            "type": "integer"
          }
        }
      },
      "ErrorResponse": {
        "description": "Standard error response returned by the API when a request fails.",
        "properties": {
          "errors": {
            "description": "Field-level validation errors, empty when not applicable.",
            "items": {
              "$ref": "#/components/schemas/InsurelyInputError"
            },
            "type": "array"
          },
          "localizedMessage": {
            "description": "Localized version of the error message, if available.",
            "example": "Invalid request",
            "type": "string"
          },
          "message": {
            "description": "Human-readable error message.",
            "example": "Invalid request",
            "type": "string"
          },
          "status": {
            "description": "HTTP status name.",
            "example": "BAD_REQUEST",
            "type": "string"
          },
          "statusCode": {
            "description": "HTTP status code.",
            "example": 400,
            "format": "int32",
            "type": "integer"
          }
        }
      },
      "ExportedCollection": {
        "properties": {
          "collectionId": {
            "description": "The ID of the collection",
            "example": "05b1fbdcaec8736925ee4309e1e4b5d2",
            "type": "string"
          },
          "contactEmail": {
            "description": "The email for the subject of the collection. If not available, no email was provided.\n",
            "example": "example@example.org",
            "type": "string"
          },
          "contactPhone": {
            "description": "The phone number for the subject of the collection. If not available, no phone number was provided.\n",
            "example": "0701740635",
            "type": "string"
          },
          "createdAt": {
            "description": "The time at which the collection took place",
            "example": "2023-01-01T12:00:00.000000Z",
            "format": "date-time",
            "type": "string"
          },
          "expiresAt": {
            "description": "The time at which the collection will no longer be available",
            "example": "2023-12-31T12:00:00.000000Z",
            "format": "date-time",
            "type": "string"
          },
          "externalUserUuid": {
            "description": "The UUID of the external user this collection belongs to, when it is linked to one. If not available, the collection is not linked to an external user. Can be used to build a Hub deep-link of the form /collections/user/{externalUserUuid}.\n",
            "example": "b3f1c2a4-8d6e-4f2b-9a1c-7e5d3b2a1f0e",
            "type": "string"
          },
          "marketingConsent": {
            "description": "Whether or not the subject of the collection has opted in for being contacted regarding marketing.\n",
            "example": true,
            "type": "boolean"
          },
          "referenceId": {
            "description": "The reference ID the collection was initiated with. If not available, no reference ID was provided when starting the collection\n",
            "example": "reference-id",
            "type": "string"
          },
          "sessionId": {
            "description": "The ID of the session in which the collection took place. If not available, the collection took place outside of a session\n",
            "example": "f0ede06b-7cb5-4861-bbee-67f23fd5a23b",
            "type": "string"
          }
        }
      },
      "InsurelyInputError": {
        "description": "Field-level validation errors, empty when not applicable."
      },
      "SessionData": {
        "description": "Session data pertaining to the person the session was created for (contact information, name,\npersonal number) and additional session metadata.\n",
        "properties": {
          "contactEmail": {
            "description": "Contact email address of the person the session was created for",
            "example": "em@ail.com",
            "type": "string"
          },
          "contactPhone": {
            "description": "Contact phone number of the person the session was created for",
            "example": "46",
            "type": "string"
          },
          "firstName": {
            "description": "First name of the person the session was created for",
            "example": "Förnamn",
            "type": "string"
          },
          "lastName": {
            "description": "Last name of the person the session was created for",
            "example": "Efternamn",
            "type": "string"
          },
          "metadata": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "Additional session metadata",
            "example": {
              "customerFlow": "email",
              "customerTier": "gold"
            },
            "type": "object"
          },
          "personalNumber": {
            "description": "Personal number of the person the session was created for",
            "example": "19401210-2887",
            "type": "string"
          }
        },
        "title": "Session Data"
      },
      "SessionEntry": {
        "description": "A session entry contains the session Id, the creation date of the session, the email address of the advisor\nthe session is assigned to (if assigned to any advisor), additional session data related to the person the\nsession was created for, a list of collections associated with the session.\n",
        "properties": {
          "advisorEmail": {
            "description": "The email address of the SST advisor that created the session.",
            "example": "insurance.advisor@wellinsured.com",
            "type": "string"
          },
          "collections": {
            "description": "A list of collections that were made through this session.",
            "items": {
              "$ref": "#/components/schemas/CollectionEntry"
            },
            "type": "array"
          },
          "creationDate": {
            "description": "Timestamp the session was created at.",
            "example": "2023-10-19T14:05:00.73636Z",
            "format": "date-time",
            "type": "string"
          },
          "sessionData": {
            "$ref": "#/components/schemas/SessionData",
            "description": "Optional additional data about the end user."
          },
          "sessionId": {
            "description": "The session Id.",
            "example": "716247ee-a75b-4f58-b962-28b71bb2ac30",
            "type": "string"
          }
        },
        "title": "Session Entry"
      },
      "SessionExportResponse": {
        "properties": {
          "currentPage": {
            "description": "The page you are currently exporting data for",
            "example": 1,
            "format": "int32",
            "type": "integer"
          },
          "sessions": {
            "description": "List containing information about exported sessions",
            "items": {
              "$ref": "#/components/schemas/SessionEntry"
            },
            "type": "array"
          },
          "totalElements": {
            "description": "The total number of elements",
            "example": 3333,
            "format": "int64",
            "type": "integer"
          },
          "totalPages": {
            "description": "The total amount of pages available to export data for",
            "example": 2,
            "format": "int32",
            "type": "integer"
          }
        }
      }
    },
    "securitySchemes": {
      "authorization-token": {
        "description": "Your API key. Requests are only accepted from IP addresses on the client's allowlist, and with a registered client certificate when mTLS is enforced for the client.",
        "in": "header",
        "name": "authorization-token",
        "type": "apiKey"
      },
      "client-id": {
        "description": "Your client ID, as used by the Prebuilt UI. Server-to-server integrations authenticate with authorization-token instead.",
        "in": "header",
        "name": "client-id",
        "type": "apiKey"
      },
      "jwt-token": {
        "bearerFormat": "JWT",
        "description": "A user session token, sent as `Authorization: Bearer <token>`.",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "contact": {
      "email": "tech@insurely.com",
      "name": "Insurely",
      "url": "https://insurely.com"
    },
    "description": "",
    "termsOfService": "https://www.insurely.com/sv/privacy-policy",
    "title": "Insurely API",
    "version": "2024-06-01"
  },
  "openapi": "3.1.0",
  "paths": {
    "/export/collections": {
      "get": {
        "description": "Returns a paginated list of collections that were performed within the date range provided. Use the `from` query parameter to set the start of the interval. Use the `to` query parameter to set the end of the interval. Both parameters must be provided in a datetime format as specified by ISO 8601, e.g. `2024-12-22T00:00:00Z`. If the response contains more than one page, use the `page` query parameter, to request subsequent pages. The page numbers are zero-indexed.\n",
        "operationId": "exportCollections",
        "parameters": [
          {
            "description": "The start of the interval to export",
            "example": "2023-01-02T00:00:00Z",
            "in": "query",
            "name": "from",
            "required": true,
            "schema": {
              "description": "The start of the interval to export",
              "example": "2023-01-02T00:00:00Z",
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "The end of the interval to export",
            "example": "2023-01-02T00:00:00Z",
            "in": "query",
            "name": "to",
            "required": true,
            "schema": {
              "description": "The end of the interval to export",
              "example": "2023-01-02T00:00:00Z",
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "The page number of the export ",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 0,
              "description": "The page number of the export ",
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CollectionExportResponse"
                }
              }
            },
            "description": "Collections successfully fetched."
          },
          "401": {
            "content": {
              "application/json": {
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/standard-error-401"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Authentication failed: the credentials are missing or invalid, the calling IP is not on the client's allowlist, or mTLS is enforced and no valid client certificate was sent. An expired session token gets 401 Token expired."
          },
          "403": {
            "content": {
              "application/json": {
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/standard-error-403"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Client is not authorized to call this endpoint."
          }
        },
        "summary": "Get collections",
        "tags": [
          "Collection export"
        ]
      }
    },
    "/export/sessions": {
      "get": {
        "deprecated": true,
        "description": "Returns a paginated list of sessions created within the date range provided.\n",
        "operationId": "exportSessions",
        "parameters": [
          {
            "description": "The start of the interval to export",
            "example": "2023-01-02T00:00:00Z",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "description": "The start of the interval to export",
              "example": "2023-01-02T00:00:00Z",
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "The end of the interval to export",
            "example": "2023-01-02T00:00:00Z",
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "description": "The end of the interval to export",
              "example": "2023-01-02T00:00:00Z",
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "The page number of the export ",
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "default": 0,
              "description": "The page number of the export ",
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "description": "The number of entries per page",
            "in": "query",
            "name": "pageSize",
            "required": false,
            "schema": {
              "default": 100,
              "description": "The number of entries per page",
              "format": "int32",
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionExportResponse"
                }
              }
            },
            "description": "Sessions successfully fetched."
          },
          "401": {
            "content": {
              "application/json": {
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/standard-error-401"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Authentication failed: the credentials are missing or invalid, the calling IP is not on the client's allowlist, or mTLS is enforced and no valid client certificate was sent. An expired session token gets 401 Token expired."
          },
          "403": {
            "content": {
              "application/json": {
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/standard-error-403"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Client is not authorized to call this endpoint."
          }
        },
        "summary": "Get sessions for a given client",
        "tags": [
          "Session export"
        ]
      }
    }
  },
  "servers": [
    {
      "description": "Production",
      "url": "https://api.insurely.com"
    },
    {
      "description": "Test",
      "url": "https://api.test.insurely.com"
    }
  ],
  "tags": [
    {
      "description": "Export session data",
      "name": "Session export"
    },
    {
      "description": "Export collection data",
      "name": "Collection export"
    }
  ]
}