> ## 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.

# विज्ञापन अभियान

> ऐसे विज्ञापन अभियान बनाएँ, पढ़ें और अपडेट करें जिनके पीछे कोई पोस्ट नहीं होती, जैसे सर्च अभियान।

अभियान एक ऐसा विज्ञापन है जो आपकी किसी पोस्ट से शुरू नहीं होता। इसका उपयोग सर्च विज्ञापनों जैसे फ़ॉर्मैट के लिए करें, जहाँ आप बजट, बिडिंग रणनीति और टार्गेटिंग सेट करते हैं, और नेटवर्क विज्ञापन बनाता है।

पहले से प्रकाशित किसी पोस्ट को प्रमोट करने के लिए, इसके बजाय [Boost Post](https://www.ayrshare.com/docs/apis/ads/facebook/boost-post.md) का उपयोग करें।

> [!NOTE]
>
> Google कैंपेन स्वीकार करता है। Google से जुड़ी खास बातों के लिए [Google सर्च अभियान](https://www.ayrshare.com/docs/apis/ads/google/search-campaigns.md) और [Google Performance Max अभियान](https://www.ayrshare.com/docs/apis/ads/google/performance-max-campaigns.md) देखें। अन्य नेटवर्क कैंपेन अनुरोध को `code: 101` के साथ अस्वीकार करते हैं, और `details` कारण बताता है। उदाहरण के लिए, Facebook पर यह `campaignCreation is not supported on facebook.` बताता है।

## एंडपॉइंट

| मेथड | पाथ | यह क्या करता है |
| - | - | - |
| `POST` | `/ads/{platform}/campaigns` | एक अभियान बनाएँ |
| `GET` | `/ads/{platform}/campaigns/{id}` | एक अभियान प्राप्त करें |
| `PUT` | `/ads/{platform}/campaigns/{id}` | एक अभियान बदलें |

`{platform}` विज्ञापन नेटवर्क है। `{id}` वह अभियान id है जो अभियान बनाते समय लौटाई गई थी। आप केवल वही अभियान पढ़ और बदल सकते हैं जो उसी यूज़र प्रोफ़ाइल द्वारा Ayrshare के माध्यम से बनाए गए हों।

## हेडर पैरामीटर

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

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

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

**Idempotency-Key** `string` *required*

अभियान बनाने के लिए आवश्यक। प्रत्येक नए अभियान के लिए एक नया यूनिक मान भेजें, जैसे UUID। यदि आप उसी key के साथ कोई अनुरोध दोहराते हैं, तो Ayrshare पहला रिस्पॉन्स `idempotentReplayed: true` के साथ चिह्नित करके लौटाता है, और कुछ भी नया नहीं बनाता। आप इसके बजाय key को body में `idempotencyKey` के रूप में भेज सकते हैं। यदि आप दोनों भेजते हैं, तो वे मेल खाने चाहिए।

## अभियान बनाएँ

`POST /ads/{platform}/campaigns`

नए अभियान `paused` स्थिति में शुरू होते हैं, जब तक आप `status: "active"` नहीं भेजते, इसलिए जब तक आप शुरू करने का निर्णय नहीं लेते, कुछ भी खर्च नहीं होता।

**accountId** `string` *required*

वह विज्ञापन खाता जिसमें अभियान बनाना है।

**name** `string` *required*

अभियान का नाम, 1 से 255 अक्षर।

**type** `string` *required*

अभियान का प्रकार: `search` या `performanceMax`। प्रत्येक नेटवर्क केवल कुछ प्रकारों का समर्थन करता है। जिस प्रकार का नेटवर्क समर्थन नहीं करता, वह `code: 101` लौटाता है और समर्थित प्रकारों की सूची देता है।

**budget** `object` *required*

**गुण**

**amount** `number` *required*

प्रति दिन कितना खर्च करना है, अधिकतम दो दशमलव स्थानों के साथ।

**type** `string` *required*

`daily`।

**currency** `string`

ISO 4217 कोड, जैसे `USD`। डिफ़ॉल्ट रूप से विज्ञापन खाते की मुद्रा। केवल कुछ नेटवर्क इसे स्वीकार करते हैं।

**bidding** `object` *required*

**गुण**

**strategy** `string` *required*

`maximizeConversions`, `maximizeConversionValue`, `targetCpa`, `targetRoas`, `maximizeClicks`, या `manualCpc`। हर नेटवर्क केवल कुछ रणनीतियों का समर्थन करता है।

**targetCpa** `number`

प्रति action लक्षित लागत। `targetCpa` के साथ आवश्यक, और किसी अन्य रणनीति के साथ स्वीकार नहीं की जाती।

**targetRoas** `number`

विज्ञापन खर्च पर लक्षित रिटर्न, उदाहरण के लिए 350% के लिए `3.5`। `targetRoas` के साथ आवश्यक, और किसी अन्य रणनीति के साथ स्वीकार नहीं किया जाता।

**euPoliticalAdvertising** `boolean` *required*

क्या अभियान EU में राजनीतिक विज्ञापन है। आपको इसे हमेशा भेजना होगा। Ayrshare इसे आपके लिए कभी नहीं भरता।

**schedule** `object`

**गुण**

**start** `string`

कब शुरू करना है: एक ISO तिथि (`2026-11-01`) या `Z` या ऑफ़सेट के साथ एक ISO तिथि-समय (`2026-11-01T09:00:00Z`)। डिफ़ॉल्ट रूप से अभी।

**end** `string`

कब रोकना है, `start` के समान फ़ॉर्मैट में। यह `start` के बाद होना चाहिए, या यदि आप `start` छोड़ देते हैं तो अभी के बाद। बिना समाप्ति तिथि के चलाने के लिए इसे छोड़ दें। जो नेटवर्क पूरे दिनों का शेड्यूल बनाता है, जैसे Google, वह एक दिन के कैंपेन के लिए `start` वाले दिन का `end` भी स्वीकार करता है।

**targeting** `object`

प्रत्येक नेटवर्क केवल कुछ टार्गेटिंग का समर्थन करता है। जिस फ़ील्ड का नेटवर्क समर्थन नहीं करता, वह `code: 101` लौटाता है।

**गुण**

**locations** `string[]`

नेटवर्क की अपनी स्थान id।

**languages** `string[]`

नेटवर्क की अपनी भाषा id।

**status** `string` (default: paused)

`active` या `paused`।

**platformOptions** `object`

केवल एक नेटवर्क के लिए विकल्प, उस नेटवर्क के नाम के अंतर्गत, उदाहरण के लिए `{ "facebook": { ... } }`। किसी अन्य नेटवर्क के विकल्प `code: 101` लौटाते हैं।

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10" \
-X POST https://api.ayrshare.com/api/ads/google/campaigns \
-d '{
  "accountId": "123-456-7890",
  "name": "Spring search",
  "type": "search",
  "budget": { "amount": 20, "type": "daily" },
  "bidding": { "strategy": "maximizeClicks" },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/spring",
      "headlines": ["Spring sale", "Shoes 30% off", "Free returns"],
      "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
      "keywords": [{ "text": "running shoes", "matchType": "phrase" }]
    }
  }
}'
```

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

fetch("https://api.ayrshare.com/api/ads/google/campaigns", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10"
  },
  body: JSON.stringify({
    "accountId": "123-456-7890",
    "name": "Spring search",
    "type": "search",
    "budget": { "amount": 20, "type": "daily" },
    "bidding": { "strategy": "maximizeClicks" },
    "euPoliticalAdvertising": false,
    "platformOptions": {
      "google": {
        "finalUrl": "https://example.com/spring",
        "headlines": ["Spring sale", "Shoes 30% off", "Free returns"],
        "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
        "keywords": [{ "text": "running shoes", "matchType": "phrase" }]
      }
    }
  })
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);
```

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

headers = {
    "Authorization": "Bearer API_KEY",
    "Idempotency-Key": "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10",
}

payload = {
  "accountId": "123-456-7890",
  "name": "Spring search",
  "type": "search",
  "budget": { "amount": 20, "type": "daily" },
  "bidding": { "strategy": "maximizeClicks" },
  "euPoliticalAdvertising": False,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/spring",
      "headlines": ["Spring sale", "Shoes 30% off", "Free returns"],
      "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
      "keywords": [{ "text": "running shoes", "matchType": "phrase" }]
    }
  }
}

r = requests.post("https://api.ayrshare.com/api/ads/google/campaigns", headers=headers, json=payload)

print(r.json())
```

```php PHP theme={"system"}
<?php
$payload = <<<'JSON'
{
  "accountId": "123-456-7890",
  "name": "Spring search",
  "type": "search",
  "budget": { "amount": 20, "type": "daily" },
  "bidding": { "strategy": "maximizeClicks" },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/spring",
      "headlines": ["Spring sale", "Shoes 30% off", "Free returns"],
      "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
      "keywords": [{ "text": "running shoes", "matchType": "phrase" }]
    }
  }
}
JSON;

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer API_KEY",
        "Content-Type: application/json",
        "Idempotency-Key: 6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10"
    ],
    CURLOPT_POSTFIELDS => $payload
]);

$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 System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
        client.DefaultRequestHeaders.Add("Idempotency-Key", "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10");

        var payload = """
            {
              "accountId": "123-456-7890",
              "name": "Spring search",
              "type": "search",
              "budget": { "amount": 20, "type": "daily" },
              "bidding": { "strategy": "maximizeClicks" },
              "euPoliticalAdvertising": false,
              "platformOptions": {
                "google": {
                  "finalUrl": "https://example.com/spring",
                  "headlines": ["Spring sale", "Shoes 30% off", "Free returns"],
                  "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
                  "keywords": [{ "text": "running shoes", "matchType": "phrase" }]
                }
              }
            }
            """;

        var response = await client.PostAsync(
            "https://api.ayrshare.com/api/ads/google/campaigns",
            new StringContent(payload, Encoding.UTF8, "application/json"));
        var content = await response.Content.ReadAsStringAsync();

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

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

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

func main() {
    payload := `{
  "accountId": "123-456-7890",
  "name": "Spring search",
  "type": "search",
  "budget": { "amount": 20, "type": "daily" },
  "bidding": { "strategy": "maximizeClicks" },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/spring",
      "headlines": ["Spring sale", "Shoes 30% off", "Free returns"],
      "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
      "keywords": [{ "text": "running shoes", "matchType": "phrase" }]
    }
  }
}`

    req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/ads/google/campaigns", strings.NewReader(payload))
    req.Header.Add("Authorization", "Bearer API_KEY")
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Idempotency-Key", "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10")

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

    body, _ := io.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 CreateCampaign {
    public static void main(String[] args) throws Exception {
        String payload = """
            {
              "accountId": "123-456-7890",
              "name": "Spring search",
              "type": "search",
              "budget": { "amount": 20, "type": "daily" },
              "bidding": { "strategy": "maximizeClicks" },
              "euPoliticalAdvertising": false,
              "platformOptions": {
                "google": {
                  "finalUrl": "https://example.com/spring",
                  "headlines": ["Spring sale", "Shoes 30% off", "Free returns"],
                  "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
                  "keywords": [{ "text": "running shoes", "matchType": "phrase" }]
                }
              }
            }
            """;

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns"))
            .header("Authorization", "Bearer API_KEY")
            .header("Content-Type", "application/json")
            .header("Idempotency-Key", "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10")
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

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

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

request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer API_KEY'
request['Content-Type'] = 'application/json'
request['Idempotency-Key'] = '6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10'
request.body = <<~JSON
  {
    "accountId": "123-456-7890",
    "name": "Spring search",
    "type": "search",
    "budget": { "amount": 20, "type": "daily" },
    "bidding": { "strategy": "maximizeClicks" },
    "euPoliticalAdvertising": false,
    "platformOptions": {
      "google": {
        "finalUrl": "https://example.com/spring",
        "headlines": ["Spring sale", "Shoes 30% off", "Free returns"],
        "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
        "keywords": [{ "text": "running shoes", "matchType": "phrase" }]
      }
    }
  }
JSON

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

puts response.body
```

सफल create `status: "success"`, `campaignId`, और अभियान की अपनी स्थिति `campaignStatus` (`active` या `paused`) के रूप में लौटाता है। Get और update भी इसी तरह लौटाते हैं।

## अभियान प्राप्त करें

`GET /ads/{platform}/campaigns/{id}`

अभियान को वैसे ही लौटाता है जैसे नेटवर्क उसकी रिपोर्ट करता है। जो अभियान आपका नहीं है, या मौजूद नहीं है, वह `code: 400` लौटाता है।

## अभियान अपडेट करें

`PUT /ads/{platform}/campaigns/{id}`

इनमें से कम से कम एक फ़ील्ड भेजें। अभियान बनाने के बाद आप `type`, `accountId`, या `euPoliticalAdvertising` नहीं बदल सकते।

**name** `string`

अभियान का नया नाम।

**status** `string`

`active` या `paused`। जो अनुरोध केवल `status: "paused"` भेजता है, उसे तब ब्लॉक नहीं किया जाता जब Ayrshare ने उस नेटवर्क पर विज्ञापन रोक दिए हों। इसके लिए फिर भी एक लिंक किया गया नेटवर्क आवश्यक है, और यदि नेटवर्क स्वयं डाउन है तो यह फिर भी विफल हो सकता है।

**budget** `object`

`{ "amount": number }`: प्रति दिन खर्च करने के लिए नई राशि।

**schedule** `object`

`{ "end": string }`: नई समाप्ति तिथि, `schedule.start` के समान फ़ॉर्मैट में। यह अभियान की शुरुआत के बाद होनी चाहिए। जो नेटवर्क पूरे दिनों का शेड्यूल बनाता है, जैसे Google, वह शुरुआत वाला दिन भी स्वीकार करता है।

## त्रुटियाँ

इन त्रुटियों में एक Ayrshare `code` होता है:

| कोड | कब |
| - | - |
| `101` | अनुरोध अमान्य है, नेटवर्क अभियानों या इस अभियान प्रकार का समर्थन नहीं करता, या idempotency key अनुपस्थित है। `details` बताता है कि कौन-सा कारण है। Ayrshare नेटवर्क के लिंक होने की पुष्टि करने के बाद key की जाँच करता है, इसलिए अनलिंक प्रोफ़ाइल को पहले "not linked" (लिंक नहीं है) त्रुटि मिलती है। |
| `400` | अभियान आपका नहीं है या मौजूद नहीं है। |
| `424` | इस नेटवर्क पर विज्ञापन अस्थायी रूप से अनुपलब्ध हैं। |

कोई create इनमें से किसी HTTP स्टेटस के साथ भी जवाब दे सकता है। इसके body में कोई `code` नहीं होता, केवल `{ "action": "createAdCampaign", "status": "error", "message": "..." }`:

| HTTP स्टेटस | कब |
| - | - |
| `409` | idempotency key का उपयोग किसी अलग अनुरोध के साथ किया गया था, या इस key वाला अनुरोध अभी भी प्रगति में है। नई key के साथ पुनः प्रयास न करें। पहले विज्ञापन खाते की जाँच करें। |
| `503` | Ayrshare idempotency key को सुरक्षित रूप से आरक्षित नहीं कर सका, इसलिए कुछ भी नहीं बनाया गया। बाद में उसी key के साथ पुनः प्रयास करें। |


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