> For the complete documentation index, see [llms.txt](https://docs.gardenlab.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gardenlab.io/api/partners-api.md).

# Partners API

## Introduction

A partner API is being developed and allows third party to trigger actions in a NFT collection on Gardenlab.&#x20;

For now, the API allows partners to trigger NFT creation and reservation for later claim by the user. The claim shall be performed by the user, after logging in with its email. It also allows to consume an interaction on a NFT, designated by the owner's email address. The interaction shall be created and configured beforehand on the collection admin tool.

An API key and a configured collection are required to properly perform those actions.

Swagger demo API : <https://api-docs-demo.gardenlab.io/>&#x20;

## Description

### Configuration

#### Interactions

{% openapi src="/files/k7wMOpSOlzdSAfnJgPSh" path="/saveActionInteraction" method="post" %}
[Partner\_API.yaml](https://1709637223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKOEfBdbqPRR5N4ZYARth%2Fuploads%2FGiy9IyAurhNwxRw9QGJp%2FPartner_API.yaml?alt=media\&token=4635299c-e916-4d58-bd62-4cca5284697e)
{% endopenapi %}

### Operation

#### User creation

{% openapi src="/files/9HBE2sPcewrnpTfv2oEk" path="/newUserForPartner" method="post" %}
[Partner\_API.yaml](https://1709637223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKOEfBdbqPRR5N4ZYARth%2Fuploads%2Fv05zQ8EgCIRK5tAzMel5%2FPartner_API.yaml?alt=media\&token=5b69f400-af4f-47bf-b8bb-b862abe00087)
{% endopenapi %}

**Note**: When creating a NFT for a user, this NFT is prepared but not minted. The mint of the NFT occurs when the user claims it using the email address.

#### Action

{% openapi src="/files/k7wMOpSOlzdSAfnJgPSh" path="/newActionForUser" method="post" %}
[Partner\_API.yaml](https://1709637223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKOEfBdbqPRR5N4ZYARth%2Fuploads%2FGiy9IyAurhNwxRw9QGJp%2FPartner_API.yaml?alt=media\&token=4635299c-e916-4d58-bd62-4cca5284697e)
{% endopenapi %}

**Note**: The action saved for a NFT is applied if the NFT is minted or not.

#### Mint token

{% openapi src="/files/9HBE2sPcewrnpTfv2oEk" path="/mintTokenForUser" method="post" %}
[Partner\_API.yaml](https://1709637223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKOEfBdbqPRR5N4ZYARth%2Fuploads%2Fv05zQ8EgCIRK5tAzMel5%2FPartner_API.yaml?alt=media\&token=5b69f400-af4f-47bf-b8bb-b862abe00087)
{% endopenapi %}

### Getters

{% openapi src="/files/k7wMOpSOlzdSAfnJgPSh" path="/getNftByTokenId" method="get" %}
[Partner\_API.yaml](https://1709637223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKOEfBdbqPRR5N4ZYARth%2Fuploads%2FGiy9IyAurhNwxRw9QGJp%2FPartner_API.yaml?alt=media\&token=4635299c-e916-4d58-bd62-4cca5284697e)
{% endopenapi %}

{% openapi src="/files/k7wMOpSOlzdSAfnJgPSh" path="/getAllInteractions" method="get" %}
[Partner\_API.yaml](https://1709637223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKOEfBdbqPRR5N4ZYARth%2Fuploads%2FGiy9IyAurhNwxRw9QGJp%2FPartner_API.yaml?alt=media\&token=4635299c-e916-4d58-bd62-4cca5284697e)
{% endopenapi %}

{% openapi src="/files/k7wMOpSOlzdSAfnJgPSh" path="/getAllInteractionScansForToken" method="get" %}
[Partner\_API.yaml](https://1709637223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKOEfBdbqPRR5N4ZYARth%2Fuploads%2FGiy9IyAurhNwxRw9QGJp%2FPartner_API.yaml?alt=media\&token=4635299c-e916-4d58-bd62-4cca5284697e)
{% endopenapi %}

{% openapi src="/files/R8FhUhM57m6IgMsmzYIn" path="/getBlockchainTxForToken" method="get" %}
[Partner\_API.yaml](https://1709637223-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKOEfBdbqPRR5N4ZYARth%2Fuploads%2Fve6acbrKlrNyXXfw4qi2%2FPartner_API.yaml?alt=media\&token=3e527bb1-d9db-42e7-bfc2-d3b6049d15d4)
{% endopenapi %}

## Webhooks

It is also possible to set up webhooks to get notified about some specific events occuring in Gardenlab.

The failure object is sent only when there is no "hope" about succeeding in performing the blockchain transactions. Gardenlab system is designed to try multiple times to perform a transaction if no fatal error occurs on the transaction.

### New interaction with blockchain update:

#### Type :&#x20;

```typescript
newBcInteraction
```

#### Header:

```typescript
"X-API-key": string // The API key configured by the partner
```

#### Success Content:

```javascript
{
    sucess: true,
    contract: string, // The contract address
    tokenId: string, // The token ID
    actionType: string, // The webhook/action type (newBcInteraction)
    actionAtInSeconds: string, // The date of the action in seconds
    at: {"_seconds": number, "_nanoseconds": number}, // The date in an object
    transactionUrl: string, // The blockchain explorer page for this transaction
    txHash: string, // The blockchain transaction hash
    newUri: string, // The new URI of the token
}
```

#### &#x20;Failure Content:

```javascript
{
    sucess: false,
    error: string,
    contract: string, // The contract address
    tokenId: string, // The token ID
    actionType: string, // The webhook/action type (newBcInteraction)
    actionAtInSeconds: string, // The date of the action in seconds
    at: {"_seconds": number, "_nanoseconds": number}, // The date in an object
}
```

###

### New NFT minted

#### Type :&#x20;

```typescript
newBcNftMint
```

#### Header:

```typescript
"X-API-key": string // The API key configured by the partner
```

#### Success content:

```javascript
{
    success: true,
    contract: string, // The contract address
    tokenId: string, // The token ID
    actionType: string, // The webhook/action type (newBcNftMint)
    at: {"_seconds": number, "_nanoseconds": number}, // The date in an object
    transactionUrl: string, // The blockchain explorer page for this transaction
    txHash: string, // The blockchain transaction hash
}
```

#### Failure content:

```javascript
{
    success: false,
    error: string, // The error message
    contract: string, // The contract address
    tokenId: string, // The token ID
    actionType: string, // The webhook/action type (newBcNftMint)
    at: {"_seconds": number, "_nanoseconds": number}, // The date in an object
}
```
