> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Ad

> Update an Ad

Update the status of a boosted ad to make it active, paused, deleted, or archived.

* For a boost added to your own campaign or ad set with `attachTo`, the new status applies only to what the boost created: the ad, and the ad set when the boost created it. The campaign or ad set you named in `attachTo` keeps its own status. The ad runs only while the campaign and ad set above it are active. See [Boost into an Existing Campaign or Ad Set](/docs/apis/ads/instagram/boost-post#attach-to).
* An ad that Ayrshare has no record of can be paused, deleted or archived, but not set to `active`. That request returns a `400`. Contact support with the ad id.

## Header Parameters

**Authorization** `string` *required*

[API Key](/docs/apis/overview#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](/docs/apis/overview#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## Body Parameters

**adId** `string` *required*

The boosted ad ID to update.

**status** `string` *required*

The status of the ad. Values: `active`, `paused`, `deleted`, or `archived`.

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X PUT https://api.ayrshare.com/api/ads/instagram/ads \
-d '{"adId": "1234567890", "status": "active"}'
```

```javascript JavaScript theme={"system"}
const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/instagram/ads", {
      method: "PUT",
      headers: {
        "Content-Type": "application/json",
        "Authorization": `Bearer ${API_KEY}`
      },
      body: JSON.stringify({ adId: "1234567890", status: "active" })
    })
      .then((res) => res.json())
      .then((json) => console.log(json))
      .catch(console.error);
```

```python Python theme={"system"}
import requests

headers = {'Authorization': 'Bearer API_KEY'}

r = requests.put('https://api.ayrshare.com/api/ads/instagram/ads', headers=headers, json={"adId": "1234567890", "status": "active"})

print(r.json())
```

```php PHP theme={"system"}
<?php
$curl = curl_init();

curl_setopt_array($curl, [
        CURLOPT_URL => "https://api.ayrshare.com/api/ads/instagram/ads",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer API_KEY",
        "Content-Type: application/json"
    ],
    CURLOPT_CUSTOMREQUEST => "PUT",
    CURLOPT_POSTFIELDS => json_encode(["adId" => "1234567890", "status" => "active"])
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error: " . $err;
} else {
    echo $response;
}
?>
```

```csharp C# theme={"system"}
using System;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");

        var response = await client.PutAsync("https://api.ayrshare.com/api/ads/instagram/ads", new StringContent(JsonConvert.SerializeObject(new { adId = "1234567890", status = "active" }), Encoding.UTF8, "application/json"));
        var content = await response.Content.ReadAsStringAsync();

        Console.WriteLine(content);
    }
}
```

```go Go theme={"system"}
package main

import (
    "strings"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    client := &http.Client{}
    req, _ := http.NewRequest("PUT", "https://api.ayrshare.com/api/ads/instagram/ads", strings.NewReader(`{"adId":"1234567890","status":"active"}`))

    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Authorization", "Bearer API_KEY")

    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={"system"}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class GetAdSpend {
    public static void main(String[] args) {
        HttpClient client = HttpClient.newHttpClient();

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.ayrshare.com/api/ads/instagram/ads"))
            .header("Authorization", "Bearer API_KEY")
            .header("Content-Type", "application/json")
            .PUT(HttpRequest.BodyPublishers.ofString("{\"adId\":\"1234567890\",\"status\":\"active\"}"))
            .build();

        try {
            HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
            System.out.println(response.body());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

```ruby Ruby theme={"system"}
require 'net/http'
require 'json'
require 'uri'

uri = URI.parse('https://api.ayrshare.com/api/ads/instagram/ads')

request = Net::HTTP::Put.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer API_KEY'
request.body = JSON.generate({ adId: "1234567890", status: "active" })

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
http.request(request)
end

puts response.body
```

```json 200: Success theme={"system"}
{
    "status": "success",
    "adId": "6691084804905",
    "requestedStatus": "ACTIVE"
}
```

```json 400: Ad update error theme={"system"}
{
  "action": "request",
  "status": "error",
  "code": 101,
  "message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
  "details": "Invalid status: actives. Status must be either 'active', 'paused', 'deleted', or 'archived'."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.