# /quotes

**Create a quote**

{% hint style="info" %}
This is a **public** API endpoint. You can hit this endpoint for client-side code by just providing ***client\_id\_key*** in the header. View [authentication](https://swallow-1.gitbook.io/swallow/developer-api/authentication) to find out more. Public APIs have **/public/** within the endpoint url.
{% endhint %}

{% openapi src="<https://1110149073-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fu89vYHjuY9Vj4vhZX5IZ%2Fuploads%2FHq1XfYRcYOI2opkc1T2i%2Fopenapi_5.json?alt=media&token=0660dd0c-e092-481e-82ed-71adc8066362>" path="/sw/public/quotes/{project\_reference}" method="post" %}
[openapi\_5.json](https://1110149073-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fu89vYHjuY9Vj4vhZX5IZ%2Fuploads%2FHq1XfYRcYOI2opkc1T2i%2Fopenapi_5.json?alt=media\&token=0660dd0c-e092-481e-82ed-71adc8066362)
{% endopenapi %}

{% hint style="info" %}
This is a private API endpoint. You have to hit it with both ***client\_id\_key*** and ***client\_secret\_key*** in the header. You should only hit this POST endpoint server-side.
{% endhint %}

{% openapi src="<https://1110149073-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fu89vYHjuY9Vj4vhZX5IZ%2Fuploads%2FHq1XfYRcYOI2opkc1T2i%2Fopenapi_5.json?alt=media&token=0660dd0c-e092-481e-82ed-71adc8066362>" path="/sw/quotes/{project\_reference}" method="post" %}
[openapi\_5.json](https://1110149073-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fu89vYHjuY9Vj4vhZX5IZ%2Fuploads%2FHq1XfYRcYOI2opkc1T2i%2Fopenapi_5.json?alt=media\&token=0660dd0c-e092-481e-82ed-71adc8066362)
{% endopenapi %}

The **request body** should match the inputs that are defined within your Swallow pricing project. You can see the desired payload by looking at the **Try** page of any project or project version. For example:

```
{
        "name": "Smith",
        "date_of_birth": "1990-01-01",
        "country": "UK",
        "duration_days": 5,
        "is_healthy": true
}
```

The **response body** will return the priced quote with the outputs that are defined within your Swallow pricing project.

```
{
	"company_reference": "098ae4f2-3af8-4740-8760-5d312e46742c",
	"project_reference": "1085e088-5501-4cc0-babd-464c6ae04707",
	"version_reference": "862360ff-fe53-40e1-8f11-57bf9a6f7477",
	"quote_reference": "e8733d88-b560-44d4-8c03-b2366dfd2cbb",
	"version": 1,
	"indicators": "bob@smith.com::Smith",
	"output": {
		"commission": 31.46,
		"tax": 23.595,
		"result": 212.36,
		"valid": true
	},
	"input": {
	        "name": "Smith",
	        "date_of_birth": "1990-01-01",
	        "country": "UK",
	        "duration_days": 5,
	        "is_healthy": true
	},
	"created_at": "2023-09-20T09:32:43.865Z",
}
```

To respond with debugging details, provide ***?debug=true*** as a query parameter within the endpoint. This will return an additional parameter called **debug** with granular detail of how the quote was created. This ***will not*** work on the public quote endpoint.

```
{
    ...    
    "debug": {
        "timer": [],
        "errors": [],
        "exclusions": [],
        "refers": [],
        "excesses": [],
        "endorsements": [],
        "indicators": {},
        "steps": {}
    }
    ...
}
```

**Retrieve quotes**

{% openapi src="<https://1110149073-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fu89vYHjuY9Vj4vhZX5IZ%2Fuploads%2FHq1XfYRcYOI2opkc1T2i%2Fopenapi_5.json?alt=media&token=0660dd0c-e092-481e-82ed-71adc8066362>" path="/sw/quotes" method="get" %}
[openapi\_5.json](https://1110149073-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fu89vYHjuY9Vj4vhZX5IZ%2Fuploads%2FHq1XfYRcYOI2opkc1T2i%2Fopenapi_5.json?alt=media\&token=0660dd0c-e092-481e-82ed-71adc8066362)
{% endopenapi %}

Quotes can be fetched in bulk or filtered (via a **?search** query) on ***indicators*** that are defined in the inputs of Swallow pricing models. ***Indicators*** are up to 4 defined input parameters that can be searched (e.g. name, password, registration, zip code, postcode).

```
https://api.llow.io/sw/quotes?search=bob@smith.com
```

Quotes can also be filtered on a specific ***version\_reference*** or ***project\_reference***.

```
https://api.llow.io/sw/quotes?version_reference=862360ff-fe53-40e1-8f11-57bf9a6f7477
```

**Retrieve quote detail**

{% openapi src="<https://1110149073-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fu89vYHjuY9Vj4vhZX5IZ%2Fuploads%2FHq1XfYRcYOI2opkc1T2i%2Fopenapi_5.json?alt=media&token=0660dd0c-e092-481e-82ed-71adc8066362>" path="/sw/quotes/{quote\_reference}" method="get" %}
[openapi\_5.json](https://1110149073-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fu89vYHjuY9Vj4vhZX5IZ%2Fuploads%2FHq1XfYRcYOI2opkc1T2i%2Fopenapi_5.json?alt=media\&token=0660dd0c-e092-481e-82ed-71adc8066362)
{% endopenapi %}

Each quote has a unique ***quote\_reference*** that is used within the quote request.

To respond with debugging details, provide ***?debug=true*** as a query parameter within the endpoint. This will return an additional parameter called **debug** with granular detail of how the quote was created.

```
{
	"project_reference": "1085e088-5501-4cc0-babd-464c6ae04707",
	"version_reference": "862360ff-fe53-40e1-8f11-57bf9a6f7477",
	"quote_reference": "e8733d88-b560-44d4-8c03-b2366dfd2cbb",
	"meta": {
		"project_reference": "1085e088-5501-4cc0-babd-464c6ae04707",
		"version_reference": "862360ff-fe53-40e1-8f11-57bf9a6f7477",
		"quote_reference": "2ebc2426-772f-4f10-af63-25110554d35b",
		"company_reference": "098ae4f2-3af8-4740-8760-5d312e46742c",
		"version": 1
	},
	"output": {
		"commission": 31.46,
		"tax": 23.595,
		"result": 212.36,
		"valid": true
	},
	"input": {
	        "name": "smith",
	        "date_of_birth": "1990-01-01",
	        "country": "UK",
	        "duration_days": 5,
	        "is_healthy": true
	},
	"created_at": "2023-09-20T09:32:43.865Z",
	"debug": {}
}
```

**Quote storage period**

Different account types will store quotes for different periods of time.

| Account Type  | Period       |
| ------------- | ------------ |
| Free          | 3 Months     |
| Pay-as-you-go | 12 Months    |
| Professional  | indefinitely |
| Enterprise    | indefinitely |
