# Mirror

**`campaign/{campaign}/mirror`**, where **`{campaign}`** is a placeholder representing the campaign ID.

### Request example:

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

```
curl -X POST 'https://api.croplink.net/public/v1/mirror/campaign/1/mirror' \
--header 'Authorization: Bearer [yourAuthKey]' \
--header 'Content-Type: application/json' \
--data '{
  "mirror_endpoint": "https://your-mirror.com"
}'
```

{% endtab %}
{% endtabs %}

{% code title="Example response" overflow="wrap" lineNumbers="true" %}

```json5
{
   "mirror": {
        "id": 1,
        "campaign_id": 1,
        "target_url": "https://your-mirror.com",
        "clicks": 0,
        "updated_externally": true,
        "updated_externally_at": "2025-01-27T17:39:41.000000Z",
        "created_at": "2025-01-27T17:39:35.000000Z",
        "updated_at": "2025-01-27T17:39:41.000000Z"
    }
}
```

{% endcode %}

#### Request Body Descriptions <a href="#request-body-descriptions" id="request-body-descriptions"></a>

| Body parameter                | Description          |
| ----------------------------- | -------------------- |
| mirror\_endpoint *(required)* | Mirror to be setted. |

#### Error Responses

Make sure to check [common errors](/docs/best-practices/error-handling.md) before.

<table data-full-width="true"><thead><tr><th width="140">HTTP code</th><th width="471">Response body</th><th>Description</th></tr></thead><tbody><tr><td>404</td><td><pre class="language-json"><code class="lang-json">{
    "message": "No query results for model [App\\Models\\Campaign] 1"
}
</code></pre></td><td>The campaign with the specified ID in the URL: campaign/{campaign}/mirror could not be found.</td></tr><tr><td>403</td><td><pre class="language-json"><code class="lang-json">{
    "message": "This action is unauthorized."
}
</code></pre></td><td>One potential reason:<br>- Before updating the mirror, ensure that <strong>it's created</strong> in the settings.<br><br>- The mirror <strong>cannot</strong> be updated <strong>for the default campaign</strong>.<br><br>- <strong>You</strong> must be <strong>the owner of the campaign</strong> to proceed.</td></tr><tr><td>422</td><td><pre class="language-json"><code class="lang-json"><strong>{
</strong><strong>    "message": "The mirror endpoint field is required.",
</strong>    "errors": {
        "mirror_endpoint": [
            "The mirror endpoint field is required."
        ]
    }
}
</code></pre></td><td>Validation error.</td></tr></tbody></table>


---

# 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://croplink.gitbook.io/docs/api-reference/mirror.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.
