> For the complete documentation index, see [llms.txt](https://developers.bloomcredit.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.bloomcredit.io/data-access/batch-ordering.md).

# Batch Ordering

Batch ordering allows Bloom's partners to pull credit data for multiple consumers at a time on some predefined cadence.

To get started with batch ordering for your use case, follow these steps:

## 1. Create a Subscription

In order to start batch ordering, you must first create a Subscription.

To create the subscription, you'll need to send a POST request to our [Create Subscription](/reference/data-access/subscriptions/build-a-new-subscription.md) endpoint (replacing all `{{var}}` with your variables):

{% tabs %}
{% tab title="curl" %}

```bash
curl --location --request POST 'https://sandbox.bloom.dev/v2/data-access/subscriptions' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "data": {
        "type": "subscription",
        "attributes": {
            "organization_id": "{{organization_id}}",
            "sku": "{{sku_name}}",
            "frequency": "WEEKLY"
        }
    }
}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
POST /v2/data-access/subscriptions/ HTTP/1.1
Host: sandbox.bloom.dev
Authorization: Bearer {{access_token}}
Content-Type: application/json
{
    "data": {
        "type": "subscription",
        "attributes": {
            "organization_id": "{{portfolio_id}}",
            "sku": "{{sku_name}}",
            "output_credentials": "test",
            "frequency": "WEEKLY"
        }
    }
}
```

{% endtab %}

{% tab title="JavaScript - Fetch" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer {{access_token}}");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
    "data": {
        "type": "subscription",
        "attributes": {
            "organization_id": "{{portfolio_id}}",
            "sku": "{{sku_name}}",
            "output_credentials": "test",
            "frequency": "WEEKLY"
        }
    }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://sandbox.bloom.dev/v2/data-access/subscriptions/", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Python - Request" %}

```
import requests
import json

url = "https://sandbox.bloom.dev/v2/data-access/subscriptions/"

payload = json.dumps({
    "data": {
        "type": "subscription",
        "attributes": {
            "organization_id": "{{portfolio_id}}",
            "sku": "{{sku_name}}",
            "output_credentials": "test",
            "frequency": "WEEKLY"
        }
    }
})
headers = {
  'Authorization': 'Bearer {{access_token}}',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sandbox.bloom.dev/v2/data-access/subscriptions/"
  method := "POST"

  payload := strings.NewReader(`{
    "data": {
        "type": "subscription",
        "attributes": {
            "organization_id": "{{portfolio_id}}",
            "sku": "{{sku_name}}",
            "output_credentials": "test",
            "frequency": "WEEKLY"
        }
    }
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer {{access_token}}")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Subscription**

A subscription encapsulates the data:

* **Frequency** (`DAILY` / `WEEKLY` / `BIWEEKLY` / `QUADWEEKLY` )

The **Frequency** will be how often the batch order runs for the group of consumers assigned to it
{% endhint %}

## 2. Add Consumers to Subscription

After you've created the Subscription, you'll need to add Consumers you want data fetched for into the Subscription, so that when it runs it will fetch data for those consumers. To do this, you'll need to send a PATCH request to our [Subscription Consumers](/reference/data-access/subscriptions/patch-subscription-consumers.md) endpoint:

{% tabs %}
{% tab title="curl" %}

```bash
curl --location --request PATCH 'https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_add": {
                "1ce99bf0-831c-4e22-9ec6-fc353891812b": "WEEKLY",
                "1ce99bf0-831c-4e22-9ec6-fc35389181ac": "BIWEEKLY"
            }
        }
    }
}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
PATCH /v2/data-access/subscriptions/{{subscription_id}}/consumers HTTP/1.1
Host: sandbox.bloom.dev
Authorization: Bearer {{access_token}}
Content-Type: application/json

{
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_add": {
                "1ce99bf0-831c-4e22-9ec6-fc353891812b": "WEEKLY",
                "1ce99bf0-831c-4e22-9ec6-fc35389181ac": "BIWEEKLY"
            }
        }
    }
}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer {{access_token}}");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_add": {
                "1ce99bf0-831c-4e22-9ec6-fc353891812b": "WEEKLY",
                "1ce99bf0-831c-4e22-9ec6-fc35389181ac": "BIWEEKLY"
            }
        }
    }
});

var requestOptions = {
  method: 'PATCH',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers"

payload = json.dumps({
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_add": {
                "1ce99bf0-831c-4e22-9ec6-fc353891812b": "WEEKLY",
                "1ce99bf0-831c-4e22-9ec6-fc35389181ac": "BIWEEKLY"
            }
        }
    }
})
headers = {
  'Authorization': 'Bearer {{access_token}}',
  'Content-Type': 'application/json'
}

response = requests.request("PATCH", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers"
  method := "PATCH"

  payload := strings.NewReader(`{
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_add": {
                "1ce99bf0-831c-4e22-9ec6-fc353891812b": "WEEKLY",
                "1ce99bf0-831c-4e22-9ec6-fc35389181ac": "BIWEEKLY"
            }
        }
    }
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer {{access_token}}")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Removing Consumers from an existing Subscription**

You can change the operation applied from the PATCH request simply by switching the attribute `consumers_to_add` with a list of consumers with the name `consumers_to_remove`
{% endhint %}

{% tabs %}
{% tab title="curl" %}

```bash
curl --location --request PATCH 'https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_remove": [
                "1ce99bf0-831c-4e22-9ec6-fc353891812b"
            ]
        }
    }
}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
PATCH /v2/data-access/subscriptions/{{subscription_id}}/consumers HTTP/1.1
Host: sandbox.bloom.dev
Authorization: Bearer {{access_token}}
Content-Type: application/json

{
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_remove": [
                "1ce99bf0-831c-4e22-9ec6-fc353891812b"
            ]
        }
    }
}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer {{access_token}}");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_remove": [
                "1ce99bf0-831c-4e22-9ec6-fc353891812b"
            ]
        }
    }
});

var requestOptions = {
  method: 'PATCH',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers"

payload = json.dumps({
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_remove": [
                "1ce99bf0-831c-4e22-9ec6-fc353891812b"
            ]
        }
    }
})
headers = {
  'Authorization': 'Bearer {{access_token}}',
  'Content-Type': 'application/json'
}

response = requests.request("PATCH", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers"
  method := "PATCH"

  payload := strings.NewReader(`{
    "data": {
        "type": "subscription",
        "attributes": {
            "consumers_to_remove": [
                "1ce99bf0-831c-4e22-9ec6-fc353891812b"
            ]
        }
    }
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer {{access_token}}")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}

## 3. Get Subscription with Consumers

To check an existing subscription that you created in the past, it can be achieved by sending a GET request to our [Subscription Consumers](/reference/data-access/subscriptions/get-subscription-consumers.md) endpoint:

{% tabs %}
{% tab title="curl" %}

```bash
curl --location --request GET 'https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json' \
```

{% endtab %}

{% tab title="HTTP" %}

```http
GET /v2/data-access/subscriptions/{{subscription_id}}/consumers HTTP/1.1
Host: sandbox.bloom.dev
Authorization: Bearer {{access_token}}
Content-Type: application/json
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer {{access_token}}");
myHeaders.append("Content-Type", "application/json");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers"

headers = {
  'Authorization': 'Bearer {{access_token}}',
  'Content-Type': 'application/json'
}

response = requests.request("GET", url, headers=headers, data=None)
print(response.text)
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://sandbox.bloom.dev/v2/data-access/subscriptions/{{subscription_id}}/consumers"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer {{access_token}}")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}

## 4. Fetching Batch order results

Following the execution of periodic orders, result files will be uploaded to an SFTP destination of your choosing determined during batch AR onboarding with Bloom.

The uploaded files contain details of each subscription jobs, here is the schema they will be following

{% code title="JSON" %}

```json
{
 "<subscription_job_id>":  {
   //credit report  
 }, 
 "<subscription_job_id2>": {
  //credit report 
 },
 ...
}
```

{% endcode %}

Each **subscription\_job\_id** can be used to fetch a full report separately, should you need it.

Use the [Get Full Report](/reference/v2.1/data-access/get-full-report.md) endpoint with this id to fetch the full report separately.

{% hint style="info" %}
**The content of the credit report held in Batch Order response is identical to the ones documented in regular report call, to learn more see** [**Querying Reports**](/data-access/querying-reports.md)**.**
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.bloomcredit.io/data-access/batch-ordering.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
