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

# ShareLink

## ShareLink

This endpoint retrieves the share link URL for a specific templateHash, which is working with generated Templates(variants).

### Request

* Method: GET
* URL: `https://api.thebrief.ai/v1/shareLink/{{templateHash}}`

Request example:

```bash
curl --location 'https://api.thebrief.ai/v1/shareLink/zdow6r' \
--header 'Authorization: Bearer eyJ...'
```

### Response

The response will be a JSON object with the following schema:

JSON

```bash
{
    "response": {
        "shareLinkUrl": "https://app.thebrief.ai/share/d/5x6ze0x1q6zq",
        "comments": {
            "threads": []
        }
    }
}
```

## Generate ShareLink (with changes)

This endpoint allows you to generate a preview based on the provided template and element changes.

### Request

* Method: POST
* URL: `https://api.thebrief.ai/v1/shareLink/generate`
* Body:
* `templateHash` (string, required): The hash of the creative. (template or design)
* `elementsChanges` (array, required):
  * `elementName` (string, required): The name of the element.
  * `changes` (array, required):
    * `attribute` (string, required): The attribute to be changed. (Available attributes are: "LABEL", "SOURCE", "CODE",  "VISIBILITY", "FONTVARIANT", "TEXTMARKDOWN", "TEXTCOLOR", "BGCOLOR", "SVGCOLORS", "LINEHEIGHT", "LETTERSPACING" and "FONTFAMILY" )
    * `value` (string, required): The new value for the attribute.
* `generalChanges` (object, optional):&#x20;
  * `backgroundColor` (string, optional):  Any valid hexadecimal color code. The valid hexadecimal color code must satisfy the following conditions. It should start from the '#' symbol. It should be followed by the letters from a-f, A-F, and/or digits from 0-9. The length of the hexadecimal color code should be either 6 or 3, excluding the '#' symbol

Valid values for elementChanges are (depending on attribute):

* LABEL: any valid string
* SOURCE: any valid public media file link
* CODE: valid embed code
* VISIBILITY: 'true' or 'false' (as string)
* FONTVARIANT: any existing font weight value from the result of the endpoint `templates/fontVariants` for ex: '300italic', '400', '700italic', etc.
* TEXTMARKDOWN: 4 markdowns could be added to text elements
  * \[This is the text]\(This will be the link)
  * text between one star - *italic text* (\* will be transformed as italic text \*)
  * text between two pairs of stars - **bold text** (\* \* will be transformed as bold text \* \*) ( no spaces between those 2 stars)
  * text between two groups of three stars - ***bold italic text*** (\* \* \*  will be bold transformed as italic text  \* \* \*) (no spaces between those 3 stars)
* TEXTCOLOR: valid hexadecimal color code (#FFF or #FFFFFF) - used with TEXT and BUTTON layers
* BGCOLOR: valid hexadecimal color code  (#FFF or #FFFFFF) - used for changing the background for BUTTON or SHAPE layers
* SVGCOLORS: valid hexadecimal color list ("#123456", "#FFFFFF", "#AAAAAA") - used for layers which has an SVG file as source&#x20;
* LINEHEIGHT - used with TEXT layers
* LETTERSPACING - used with TEXT and BUTTON layers
* FONTFAMILY - used with TEXT and BUTTON layers

**Response:** The response for this request is a JSON object following the schema below:

```json
{
    "response": {
        "shareLinkUrl": "https://app.thebrief.ai/share/d/0z6w0dg027ol"
    }
}
```

```bash
curl --location 'https://api.thebrief.ai/v1/sharelink/generate' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ...' \
--data '{
    "templateHash": "2kzq51",
    "elementsChanges": [
        {
            "elementName": "Headline",
            "changes": [
                {
                    "attribute": "LABEL",
                    "value": "Enjoy a $0 annual \nfee and 1.5% \n cashback on purchases"
                },
                {
                    "attribute": "VISIBILITY",
                    "value: "false"
                }         
            ]
        },
        {
            "elementName": "Description",
            "changes": [
                {
                    "attribute": "LABEL",
                    "value": "Plus, earn a $300 bonus"
                },
                {
                    "attribute": "FONTVARIANT",
                    "value": "italic300"
                }
            ]
        },
        {
            "elementName": "Logo",
            "changes": [
                {
                    "attribute": "SOURCE",
                    "value": "https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/eff.svg"
                }
            ]
        },
        {
            "elementName": "shape2",
            "changes": [
                {
                    "attribute": "SOURCE",
                    "value": "https://cdn.pixabay.com/photo/2012/04/24/16/43/targets-40383_1280.png"
                }
            ]
        },
        {
            "elementName": "Image",
            "changes": [
                {
                    "attribute": "SOURCE",
                    "value": "https://cdn.pixabay.com/photo/2012/04/24/16/43/targets-40383_1280.png"
                }
            ]
        },
        {
            "elementName": "Title",
            "changes": [
                {
                    "attribute": "FONTFAMILY",
                    "value": "Unbounded"
                }
            ]
        }
    ]
}'
```

```json
{
    "response": {
        "shareLinkUrl": "https://app.thebrief.ai/share/d/dp7ke1g347o5"
    }
}
```
