> For the complete documentation index, see [llms.txt](https://claimlane-docs.gitbook.io/claimlane-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://claimlane-docs.gitbook.io/claimlane-docs/integrations/by-integration-type/b2b-credit-memo-integration.md).

# B2B Credit Memo Integration

This documentation describes the API-based workflow for B2B Credit Memo document creation between Claimlane and an ERP system.

**Workflow description:**

When a B2B ticket on Claimlane is moved to a specific status (e.g., "Ready for ERP"), it becomes eligible for ERP processing and is ready for Credit Memo creation.

The ERP system polls Claimlane for such tickets using the following endpoint:

<figure><img src="https://787834501-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdYZu0MfmFKfB61s4KoNP%2Fuploads%2Fi2IQAb7st29x2biefc5S%2Fimage%20(7).png?alt=media&amp;token=842323b2-9305-47cf-8588-b41680a779c8" alt=""><figcaption></figcaption></figure>

**GET:** [**/v2/company/b2b-tickets**](https://server-claimlane.claimlane.com/api-docs/#/company/b2b-tickets)

These are the required parameters that will identify what tickets are eligible to be polled:

1. **brandId** - ID for the brand. This will be given by Claimlane.

   brandId can be obtained using the endpoint /v2/company/suppliers with a company api key or /v2/brands with a supplier api key
2. **claimboxStatusId** - ID for the status on Claimlane (e.g., "Ready for ERP") that determines whether the ticket is eligible to be process in the ERP. This will be provided by Claimlane during account setup.
3. **supplierintegrationComplete** - Allows the ERP to query only tickets that have not yet been handled already by setting **supplierintegrationComplete: 0**

**Example request:**

```jsx
<https://server-claimlane.claimlane.com/api/v2/company/b2b-tickets?brandId={brandId}&claimboxStatusId={claimboxStatusId}&supplierintegrationComplete=0>

where {brandId} and {claimboxStatusId} are uuid's provided by Claimlane.
```

**To integrate with the ERP system, pull the following key fields from Claimlane:**

```jsx
id // if of the ticket
retailer.customerNumber // customer number of the retailer who created the ticket
claimProducts {
 productIds[] // The id of the product to be refunded, use first element
 quantity // The number of products to be refunded for this productId
}[] // List of products to be refunded

```

Once the ERP has created the Credit Memo, it must notify Claimlane by updating the ticket using this endpoint:

<figure><img src="https://787834501-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdYZu0MfmFKfB61s4KoNP%2Fuploads%2F5xwAk4FmnF18yHVgUhoJ%2Fimage%20(8).png?alt=media&amp;token=f532c56c-fdaa-42e0-9f1b-b2122a1d3f09" alt=""><figcaption></figcaption></figure>

**POST:** [**/v2/company/update-b2b-ticket/{ticketId}**](https://server-claimlane.claimlane.com/api-docs/#/company/update-b2b-ticket)

With the following body

```jsx
{
 "supplierIntegrationComplete": true,
 "isClosed": true
}
```

**"supplierIntegrationComplete": true**

This will stop the ticket from getting polled again, as it has been resolved.

**"isClosed": true**

A ticket on Claimlane will get “Archived” so it shows to Customer Service that the action has been done on the ERP and the ticket doesn’t require any further attention.

Please see full API documentation here:

<https://server-claimlane.claimlane.com/api-docs/#/>
