# Create Content

## Authorization

<mark style="color:green;">`POST`</mark> `{API_URL}/content`

Client API Key and API Secret must be passed in Authorization Headers using Basic Auth. With API Key as the Username and API Secret as the password.

#### Request Body

| Name                                        | Type                       | Description               |
| ------------------------------------------- | -------------------------- | ------------------------- |
| contentId<mark style="color:red;">\*</mark> | String                     | Content Id of the content |
| price                                       | Integer                    | price of the content      |
| categories                                  | \["category1","category2"] |                           |
| authorId                                    | String                     |                           |
| sections                                    | \["section1","section2"]   |                           |
| tags                                        | \["tag1","tag2"]           |                           |
| title<mark style="color:red;">\*</mark>     | String                     | Title of the content      |
| url<mark style="color:red;">\*</mark>       | String                     | url of the content        |
| contentType                                 | String                     |                           |
| currency                                    | String                     |                           |
| duration                                    | Integer                    | duration of the content   |

{% tabs %}
{% tab title="201: Created { "message": "New Content Created!"}" %}

{% endtab %}
{% endtabs %}

> To pick the Default Price and Default Duration for micropayment, you need to set them [here](https://client.conscent.in/client/dashboard/micropayments) and pass "price" : null and "duration" : null while registering the content.

<figure><img src="https://380225236-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcoDfVWiJBvgTq8DbifIH%2Fuploads%2F9hqKqH7H9ZhhEawRTzLV%2FScreenshot%202023-05-29%20at%2010.57.28%20AM.png?alt=media&#x26;token=69fcb317-22a1-4da9-8d73-0a74ac8cd34b" alt="" width="375"><figcaption></figcaption></figure>

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

```
 curl -X POST '{API_URL}/api/v1/content/' \
-H 'Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==' \
-H 'Content-Type: application/json' \
-d '{
 "contentId" : "testingID For Client Content",
    "duration": 30,
    "title": "Test content for API functionality",
    "price": 1,
    "currency": "INR",
    "categories": ["category1", "category2"],
    "tags": ["free", "premium", "metered"],
    "sections": ["EDITORIAL"],
    "authorId": "7589",
    "contentType": "STORY",
    "url": "www.google.com",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 3
            },
            {
                "name": "IN",
                "price": 5
            },
            {
                "name": "US",
                "price": 7
            }
        ]
    },
    "download": {
      "url": "https://yourdownloadurl.com",
      "fileName": "Download File - Name",
      "fileType": "PDF"
    },
    "pixels": {
        "facebook": {
            "pixelId": "98357934724994",
            "events": [
                {
                    "eventType": "VIEW",
                    "name": "PageView"
                },
                {
                    "eventType": "CONVERSION",
                    "name": "Purchase",
                    "data": {
                        "value": "dataValue"
                    }
                }
            ]
        },
        "google": {
            "trackingId": "G-RJDY8493"
        }
    }
}'
```

The above command returns JSON structured like this:

```json
{
    "message": "New Content Created!",
    "content": {
        "title": "Test content for API functionality",
        "price": 1,
        "currency": "INR",
        "contentId": "898",
        "duration": 30,
        "url": "www.google.com",
        "contentType": "STORY",
        "authorId": "7589",
        "priceOverrides": {
            "country": [
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b4",
                    "name": "GL",
                    "price": 3
                },
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b5",
                    "name": "IN",
                    "price": 5
                },
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b6",
                    "name": "US",
                    "price": 7
                }
            ]
        },
        "download": {
            "url": "https://www.google.com",
            "fileName": "Download File - Name",
            "fileType": "PDF",
            "s3Key": "stage/Demo Client/Download File - Name-898.pdf"
        },
        "pixels": {
            "facebook": {
                "pixelId": "98357934724994",
                "events": [
                    {
                        "eventType": "VIEW",
                        "name": "PageView"
                    },
                    {
                        "eventType": "CONVERSION",
                        "name": "Purchase",
                        "data": {
                            "value": "dataValue"
                        }
                    }
                ]
            },
            "google": {
                "trackingId": "G-RJDY8493"
            }
        },
        "categories": [
            "category1",
            "category2"
        ],
        "publicationDate": null,
        "tags": [
            "free",
            "premium",
            "metered"
        ],
        "sections": [
            "EDITORIAL"
        ]
    }
}
```

{% endtab %}

{% tab title="javaScript" %}

```
var axios = require("axios");
var data = JSON.stringify({
  contentId: "testingID For Client",
  duration: 30,
  title: "Test content for API functionality",
  price: 1,
  currency: "INR",
  url: "www.google.com",
  contentType: "STORY",
  categories: ["category1", "category2"],
  tags: ["entertainment", "sports"],
  sections: ["EDITORIAL"],
  authorId: "7589",
  priceOverrides: {
    country: [
      { name: "GL", price: 3 },
      { name: "IN", price: 5 },
      { name: "US", price: 7 },
    ],
  },
  download: {
    url: "https://yourdownloadurl.com",
    fileName: "Download File - Name",
    fileType: "PDF",
  },
  pixels: {
    facebook: {
      pixelId: "98357934724994",
      events: [
        {
          eventType: "VIEW",
          name: "PageView",
        },
        {
          eventType: "CONVERSION",
          name: "Purchase",
          data: {
            value: "dataValue",
          },
        },
      ],
    },
    google: {
      trackingId: "G-RJDY8493",
    },
  },
});

var config = {
  method: "post",
  url: "{API_URL}/api/v1/content/",
  headers: {
    Authorization:
      "Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type": "application/json",
  },
  data: data,
};

axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });
```

The above command returns JSON structured like this:

```json
{
    "message": "New Content Created!",
    "content": {
        "title": "Test content for API functionality",
        "price": 1,
        "currency": "INR",
        "contentId": "898",
        "duration": 30,
        "url": "www.google.com",
        "contentType": "STORY",
        "authorId": "7589",
        "priceOverrides": {
            "country": [
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b4",
                    "name": "GL",
                    "price": 3
                },
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b5",
                    "name": "IN",
                    "price": 5
                },
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b6",
                    "name": "US",
                    "price": 7
                }
            ]
        },
        "download": {
            "url": "https://www.google.com",
            "fileName": "Download File - Name",
            "fileType": "PDF",
            "s3Key": "stage/Demo Client/Download File - Name-898.pdf"
        },
        "pixels": {
            "facebook": {
                "pixelId": "98357934724994",
                "events": [
                    {
                        "eventType": "VIEW",
                        "name": "PageView"
                    },
                    {
                        "eventType": "CONVERSION",
                        "name": "Purchase",
                        "data": {
                            "value": "dataValue"
                        }
                    }
                ]
            },
            "google": {
                "trackingId": "G-RJDY8493"
            }
        },
        "categories": [
            "category1",
            "category2"
        ],
        "publishedAt": null,
        "tags": [
            "free",
            "premium",
            "metered"
        ],
        "sections": [
            "EDITORIAL"
        ]
    }
}
```

{% endtab %}

{% tab title="php" %}

```
       $curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "{API_URL}/api/v1/content/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>'{
    "contentId" : "testingID For Client Content",
    "duration" : 30,
    "title" : "Test content for API functionality",
    "price" : 1,
    "currency": "INR",
    "url": "www.google.com",
    "contentType": "STORY",
    "categories": ["category1", "category2"],
    "tags": ["entertainment", "sports"],
    "sections": ["EDITORIAL"],
    "authorId": "7589",
    "priceOverrides": {
        "country": [
            {
                "name": "GL",
                "price": 3
            },
            {
                "name": "IN",
                "price": 5
            },
            {
                "name": "US",
                "price": 7
            }
        ]
    },
    "download": {
      "url": "https://yourdownloadurl.com",
      "fileName": "Download File - Name",
      "fileType": "PDF"
    },
    "pixels": {
       "facebook": {
            "pixelId": "98357934724994",
            "events": [
                {
                    "eventType": "VIEW",
                    "name": "PageView"
                },
                {
                    "eventType": "CONVERSION",
                    "name": "Purchase",
                    "data": {
                        "value": "dataValue"
                    }
                }
            ]
        },
        "google": {
            "trackingId": "G-RJDY8493"
        }
    }
  }',
  CURLOPT_HTTPHEADER => array(
    "Authorization: Basic RDZXN1Y4US1NTkc0V1lDLVFYOUJQMkItOEU3QjZLRzpUNFNHSjlISDQ3TVpRWkdTWkVGVjZYUk5TS1E4RDZXN1Y4UU1ORzRXWUNRWDlCUDJCOEU3QjZLRw==",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

The above command returns JSON structured like this:

```json
{
    "message": "New Content Created!",
    "content": {
        "title": "Test content for API functionality",
        "price": 1,
        "currency": "INR",
        "contentId": "898",
        "duration": 30,
        "url": "www.google.com",
        "contentType": "STORY",
        "authorId": "7589",
        "priceOverrides": {
            "country": [
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b4",
                    "name": "GL",
                    "price": 3
                },
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b5",
                    "name": "IN",
                    "price": 5
                },
                {
                    "currency": "INR",
                    "_id": "605b25824646e9233aef61b6",
                    "name": "US",
                    "price": 7
                }
            ]
        },
        "download": {
            "url": "https://www.google.com",
            "fileName": "Download File - Name",
            "fileType": "PDF",
            "s3Key": "stage/Demo Client/Download File - Name-898.pdf"
        },
        "pixels": {
            "facebook": {
                "pixelId": "98357934724994",
                "events": [
                    {
                        "eventType": "VIEW",
                        "name": "PageView"
                    },
                    {
                        "eventType": "CONVERSION",
                        "name": "Purchase",
                        "data": {
                            "value": "dataValue"
                        }
                    }
                ]
            },
            "google": {
                "trackingId": "G-RJDY8493"
            }
        },
        "categories": [
            "category1",
            "category2"
        ],
        "publishedAt": null,
        "tags": [
            "free",
            "premium",
            "metered"
        ],
        "sections": [
            "EDITORIAL"
        ]
    }
}
```

{% endtab %}
{% endtabs %}
