---
title: "Attach Script to Link"
method: POST
path: "/links/{link_id}/scripts/{script_id}"
tags: ["Scripts"]
---

# Attach Script to Link

`POST /links/{link_id}/scripts/{script_id}`

## Request

- Base URL: `https://api.rebrandly.com/v1`
- URL: `https://api.rebrandly.com/v1/links/{link_id}/scripts/{script_id}`
- Auth: API key in header `apikey`

Attach a script/pixel to a link for tracking purposes.

**Requires:**
- Feature: `links.scripts`

**Blocked by:**
- Link deleted (status=3)
- Revoked workspace
- Revoked domain

**Workspace Type:** Classic or Gallery workspaces only.

## Path parameters

- `link_id` string, required
- `script_id` string, required

## Headers

- `Workspace` string
- `apikey` string, required

## Response `200`

Script attached successfully

- object

## Other responses

- `403`: Feature not available or insufficient permissions
- `404`: Link or script not found

---

[API](https://skmtc.dev/rebrandly/apis/rebrandly-api.md) - [All operations](https://skmtc.dev/rebrandly/apis/rebrandly-api/llms.txt) - [OpenAPI document](https://skmtc.dev/rebrandly/apis/rebrandly-api/revisions/b098bf9fb684?raw)
