> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://docs.downpay.app/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Getting started with the Downpay API

|| The Downpay API is available on the Downpay [Scale](https://getdownpay.com/pricing) plan.

The Downpay API allows you to create advanced workflows around product deposits and partial payment workflows. For example, you can use the Downpay API to accomplish the following:

* Programatically create purchase options on products.
* Assign products to existing purchase options based on a condition or a trigger.
* Collect the remaining balance on an order when a tag is applied to the order.
* Authorize the customers stored payment method in advance of an order becoming fulfilled.

---
---

###### On this page:

[API Reference](#1-api-reference)

[Getting Started](#1-getting-started)
* [Endpoint](#2-endpoint)
* [Authentication](#2-authentication)

[Making your first API Call](#1-making-your-first-api-call)

[Next steps](#1-next-steps)

---
---

# API Reference

Our [API Documentation Site](https://api.downpay.app/) contains a full reference of API calls available to you.

---
---

[Jump to top](#6-on-this-page)

# Getting Started

You will first need to retrieve your API key. You can find the key on the Settings page of the Downpay app inside your Shopify Admin.

The Downpay API is a GraphQL API, similar to Shopify's. The rest of this article assumes a basic familiarity with GraphQL. In the screenshot below we use the [Insomnia](https://insomnia.rest/) desktop client to call the Downpay API, but you can use any GraphQL client or programming environment that suits you.

## Endpoint
All API calls go through the following endpoint: 

*  https://downpay.hypehound.app/graphql
*  The HTTP method for all API calls is `POST` 

## Authentication
Calls to the API are authenticated through an HTTP header sent with each call. The header has the following properties:

Name: `Authorization`
Value: `Token <your_api_key>`

For example, if your API key is `12345abcdefg`, then the full header will be:

```html
Authorization: Token 12345abcdefg
```

With the endpoint and authorization header set, our GraphQL client configuration looks like this:


![](https://storage.crisp.chat/users/helpdesk/website/81f235024a249800/insomnia-config_1syvgg4.png)

---
---

[Jump to top](#6-on-this-page)

# Making your first API Call

After configuring your GraphQL client you are ready to issue your first API call. The following will query Downpay for all purchase options that have been created for a store so far:

```json
query AllPurchaseOptions {
    purchaseOptionGroups {
        nodes {
            createdAt
            id
            merchantCode
            productCount
        }
    }
}
```

Here we only select a few attributes of each deposit option. For a full list of attributes available to you, please consult the [API reference](https://api.downpay.app/#definition-PurchaseOptionGroup)

Provided that you have created some purchase options in the Downpay app, the return of the above query will look similar to this:

```json
{
	"data": {
		"purchaseOptionGroups": {
			"nodes": [
				{
					"createdAt": "2024-01-23T15:51:07Z",
					"id": "610697371",
					"merchantCode": "Deposit Only",
					"productCount": 1
				}
			]
		}
	}
}
```

---
---

[Jump to top](#6-on-this-page)

# Next steps

After you've successfully made your first API calls, you're ready to integrate Downpay. The API can be an excellent addition to your low-code and workflow automation tools, such as Zapier or Shopify Flow. Here are some of the things that people have built using Downpay:

* Triggering automated payment collection for a pre-order campaign days in advance of start of fulfillment.
* Creating new purchase options for every new product. Very useful when each of your products has a different deferred payment due date.
* Assigning newly created products to an existing Downpay purchase option when certain conditions are met, eg. when product cost is more than $1,000.
* Pre-order campaign automation: adding a presale product to a purchase option at a specific time, and removing it after the presale period has ended.

There are many other possibilities, depending on what works best for your store. If you need a hand using the API or would like advice on the best approach to accomplish a particular workflow, please contact us!

---
---

[Jump to top](#6-on-this-page)
