# Short Urls

Short urls are easy ways to share subscription links to your plans.

## Create a short url

<mark style="color:green;">`POST`</mark> `https://api.8pay.network/v1/:chain/on-demand/short-urls`

#### Path Parameters

| Name  | Type   | Description                                 |
| ----- | ------ | ------------------------------------------- |
| chain | string | [chain identifier](/api/overview.md#chains) |

#### Query Parameters

| Name                   | Type   | Description                            |
| ---------------------- | ------ | -------------------------------------- |
| name                   | string | name of the short url                  |
| planId                 | string | id of the                              |
| params                 | object | object containing short url param      |
| params.callbackSuccess | string | redirect url after success             |
| params.callbackError   | string | redirect url after failure             |
| params.extra           | string | extra parameters to be sent to webhook |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "dc4n3",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/dc4n3"
}
```

{% endtab %}
{% endtabs %}

## Get a list of short urls

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/short-urls`

Retrive a list of short url created by the authenticated user.

#### Path Parameters

| Name  | Type   | Description                                 |
| ----- | ------ | ------------------------------------------- |
| chain | string | [chain identifier](/api/overview.md#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "dc4n3",
            "name": "Facebook banner",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "callbackSuccess": "https://www.google.com/",
                "callbackError": "https://www.google.com/",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/dc4n3"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get short urls of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId/short-urls`

#### Path Parameters

| Name   | Type   | Description                                 |
| ------ | ------ | ------------------------------------------- |
| planId | string | ID of the plan                              |
| chain  | string | [chain identifier](/api/overview.md#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "dc4n3",
            "name": "Facebook banner",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "callbackSuccess": "https://www.google.com/",
                "callbackError": "https://www.google.com/",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/dc4n3"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a short url

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/bsc/on-demand/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                                 |
| ----- | ------ | ------------------------------------------- |
| path  | string | path of the short url                       |
| chain | string | [chain identifier](/api/overview.md#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "dc4n3",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/dc4n3"
}
```

{% endtab %}
{% endtabs %}

## Update a short url

<mark style="color:orange;">`PUT`</mark> `https://api.8pay.network/v1/bsc/on-demand/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                                 |
| ----- | ------ | ------------------------------------------- |
| path  | string | path of the short url                       |
| chain | string | [chain identifier](/api/overview.md#chains) |

#### Query Parameters

| Name                   | Type   | Description                            |
| ---------------------- | ------ | -------------------------------------- |
| name                   | string | name of the short url                  |
| planId                 | string | id of the                              |
| params                 | object | object containing short url param      |
| params.callbackSuccess | string | redirect url after success             |
| params.callbackError   | string | redirect url after failure             |
| params.extra           | string | extra parameters to be sent to webhook |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "dc4n3",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574973485,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/dc4n3"
}
```

{% endtab %}
{% endtabs %}

## Delete a short url

<mark style="color:red;">`DELETE`</mark> `https://api.8pay.network/v1/bsc/on-demand/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                                 |
| ----- | ------ | ------------------------------------------- |
| path  | string | path of the short url                       |
| chain | string | [chain identifier](/api/overview.md#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
```

{% endtab %}
{% endtabs %}


---

# 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.8pay.network/api/on-demand/short-urls.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.
