# API (V1)

## Payments

{% hint style="success" %}
**Tailored for Marketplace Integration**

offering you the ability to manage a fully functional marketplace. Empower your users to add their own NFTs and tokens by deploying their own smart contracts.&#x20;
{% endhint %}

Leverage this API to seamlessly enable token sales with our token checkout.\
To access the API, simply attach a bearer token to each request. Generate this token using the management API keys provided during onboarding.

1. **Obtain JWT Access Token**\
   To obtain a JWT access token, send a POST request to the `https://api-console.paytweed.com/auth/getAccessToken` endpoint. Include your API key and API secret in the request body. This will return a JWT access token.

{% hint style="danger" %}
Create a mechanism in your code to generate a new JWT token only when the current token has expired, rather than generating a new token for each API call.
{% endhint %}

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

```javascript
const apiKey = 'your_api_key';
const apiSecret = 'your_api_secret';

const authEndpoint = 'https://api-console.paytweed.com/auth/getAccessToken';

const payload = {
  apiKey,
  apiSecret,
};

const response = await fetch(authEndpoint, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(payload),
});

const jwt = await response.json();
```

{% endtab %}

{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --request POST --header "Content-Type: application/json" --data '{"apiKey":"<YOUR_API_KEY>","apiSecret":"<YOUR_API_SECRET>"}' https://api-console.paytweed.com/auth/getAccessToken
```

{% endcode %}
{% endtab %}
{% endtabs %}

2. For each API call you make to the `https://api-console.paytweed.com/collections` endpoint, include the JWT token in the header of your request. This ensures that the server can authenticate and authorize your requests properly.

```typescript
const headers = {
  Authorization: `Bearer ${access_token}`,
  'Content-Type': 'application/json',
};
```

### Tokens and Collections&#x20;

#### Add

Send a `POST` request to the `https://api-console.paytweed.com/collections` endpoint, including an array of objects that represent the details of the NFT collection or In-Platform Token.

**The required properties for each object are:**

<details>

<summary><code>name</code> <mark style="color:orange;background-color:yellow;">Required</mark> </summary>

Type: `String`

**Description:** The name of the NFT Collection or In-Platform Token

**Best practice:** Try to keep names short so the full name will appear in every modal

</details>

<details>

<summary><code>blockchain</code> <mark style="color:orange;background-color:yellow;">Required</mark> </summary>

Type: `String`

**Description:** The name of the blockchain associated with the NFT Collection or In-Platform Token

See all the supported blockchains in [Supported Blockchains](broken://pages/hjFlDmpeKNzDh1QIowD2).

</details>

<details>

<summary><code>contractAddress</code> <mark style="color:orange;background-color:yellow;">Required</mark> </summary>

Type: `String`

**Description:** The address of the smart contract associated with the NFT Collection or In-Platform Token

</details>

<details>

<summary><code>whitelisted</code> <mark style="color:orange;background-color:yellow;">Required</mark> </summary>

Type: `String`

**Description:** A boolean value indicating if the NFT Collection or In-Platform Token is whitelisted

</details>

<details>

<summary><code>whitelistingInfo</code> <mark style="color:orange;background-color:yellow;">Required</mark> </summary>

Type: JSON object

**Description:** to pass your whitelist information to my endpoint, format it as follows

**Example:** \
`{ "list": { "wallets": [ "0x48...0412" ] }, "emails": [ "test@test.com" ] }`

</details>

```typescript
const tokens = [
    {
      name: 'Collection 1',
      contractAddress: '0x123456789',
      blockchain: 'Ethereum',
      whitelisted: false,
      whitelistingInfo: '{}'
    },
    {...another token}]
```

#### Retrieve

To retrieve all the NFT Collections or In-Platform Tokens in your console, send a `GET` request to the `https://api-console.paytweed.com/collections` endpoint.&#x20;

The response will contain the information about all of the NFT Collections or In-Platform Tokens available.

#### Delete

To delete a specific NFT Collection or In-Platform Token, make a `DELETE` request to the `https://api-console.paytweed.com/collection/{token_Id}` endpoint, where `{token_Id}` represents the ID of the NFT Collection you want to delete.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.paytweed.com/developer-tools/api/api-v1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
