# Create tweet

<mark style="color:green;">`POST`</mark> `https://us-central1-appgregator.cloudfunctions.net/twitter/tweet/create-tweet/`

#### Headers

| Name                                        | Type   | Description                      |
| ------------------------------------------- | ------ | -------------------------------- |
| x-api-key<mark style="color:red;">\*</mark> | String | 43c464439b5507293ba7b315c9875907 |

#### Request Body

| Name                                               | Type   | Description                                 |
| -------------------------------------------------- | ------ | ------------------------------------------- |
| name<mark style="color:red;">\*</mark>             | String | qantor.co.id                                |
| connection\_name<mark style="color:red;">\*</mark> | String | twitter-1                                   |
| consumer\_key<mark style="color:red;">\*</mark>    | String | A2e5O.....                                  |
| consumer\_secret<mark style="color:red;">\*</mark> | String | rfIzsxYoLbzb.......                         |
| access\_token<mark style="color:red;">\*</mark>    | String | 245297600-2ESc.....                         |
| token\_secret<mark style="color:red;">\*</mark>    | String | d2dmLjbuK4AYY.....                          |
| text<mark style="color:red;">\*</mark>             | String | testing appgregator api service @RonaldAdrs |

{% tabs %}
{% tab title="201: Created Created" %}

```javascript
{
    "id": "1542718751119925250",
    "text": "testing appgregator api service @RonaldAdrs"
}
```

{% endtab %}

{% tab title="403: Forbidden Tweet with duplicate content" %}

```javascript
{
    "type": "response",
    "code": 403,
    "error": {
        "detail": "You are not allowed to create a Tweet with duplicate content.",
        "type": "about:blank",
        "title": "Forbidden",
        "status": 403
    },
    "rateLimit": {
        "limit": 200,
        "remaining": 198,
        "reset": 1656648687
    },
    "headers": {
        "date": "Fri, 01 Jul 2022 03:57:35 UTC",
        "server": "tsa_b",
        "set-cookie": [
            "guest_id=v1%3A165664785563383141; Max-Age=34214400; Expires=Tue, 01 Aug 2023 03:57:35 GMT; Path=/; Domain=.twitter.com; Secure; SameSite=None"
        ],
        "api-version": "2.45",
        "content-type": "application/json; charset=utf-8",
        "cache-control": "no-cache, no-store, max-age=0",
        "content-length": "131",
        "x-access-level": "read-write",
        "x-frame-options": "SAMEORIGIN",
        "content-encoding": "gzip",
        "x-xss-protection": "0",
        "x-rate-limit-limit": "200",
        "x-rate-limit-reset": "1656648687",
        "content-disposition": "attachment; filename=json.json",
        "x-content-type-options": "nosniff",
        "x-rate-limit-remaining": "198",
        "strict-transport-security": "max-age=631138519",
        "x-response-time": "45",
        "x-connection-hash": "12c548b0e641c02f54c19f944b43713ebe701dd304a5144f4534277a84975413",
        "connection": "close"
    }
}
```

{% endtab %}
{% endtabs %}

<details>

<summary>Body JSON</summary>

```
{
    "name" : "qantor.co.id",
    "connection_name" : "twitter-1",
    "consumer_key" : "A2e5O.....",
    "consumer_secret" : "rfIzsxYoLbzb.......",
    "access_token" : "245297600-2ESc.....",
    "token_secret" : "d2dmLjbuK4AYY.....",        
    "text" : "testing appgregator api service @RonaldAdrs"
}
```

</details>

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

```shell
curl --location --request POST 'https://us-central1-appgregator.cloudfunctions.net/twitter/tweet/create-tweet' \
--header 'x-api-key: 43c464439b5507293ba7b315c9875907' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name" : "qantor.co.id",
    "connection_name" : "twitter-1",
    "consumer_key" : "A2e5O.....",
    "consumer_secret" : "rfIzsxYoLbzb.......",
    "access_token" : "245297600-2ESc....",
    "token_secret" : "d2dmLjbuK4AYY.....",        
    "text" : "testing appgregator api service @RonaldAdrs"
}'
```

{% endtab %}

{% tab title="NodeJs - Axios" %}

```javascript
var axios = require('axios');
var data = JSON.stringify({
  "name": "qantor.co.id",
  "connection_name": "twitter-1",
  "consumer_key": "A2e5O.....",
  "consumer_secret": "rfIzsxYoLbzb.......",
  "access_token": "245297600-2ESc.....",
  "token_secret": "d2dmLjbuK4AYY.....",
  "text": "testing appgregator api service @RonaldAdrs"
});

var config = {
  method: 'post',
  url: 'https://us-central1-appgregator.cloudfunctions.net/twitter/tweet/create-tweet',
  headers: { 
    'x-api-key': '43c464439b5507293ba7b315c9875907', 
    'Content-Type': 'application/json'
  },
  data : data
};

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

```

{% endtab %}

{% tab title="PHP - cURL" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://us-central1-appgregator.cloudfunctions.net/twitter/tweet/create-tweet',
  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 =>'{
    "name" : "qantor.co.id",
    "connection_name" : "twitter-1",
    "consumer_key" : "A2e5O.....",
    "consumer_secret" : "rfIzsxYoLbzb.......",
    "access_token" : "245297600-2ESc.....",
    "token_secret" : "d2dmLjbuK4AYY.....",        
    "text" : "testing appgregator api service @RonaldAdrs"
}',
  CURLOPT_HTTPHEADER => array(
    'x-api-key: 43c464439b5507293ba7b315c9875907',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% endtab %}
{% endtabs %}
