# Posts

## Get a Post by ID

<mark style="color:blue;">`GET`</mark> `https://api.tiny.plus/v2/updates/{{id}}`

This endpoint allows you to get a single news feed post.

#### Path Parameters

| Name | Type   | Description       |
| ---- | ------ | ----------------- |
| id   | number | ID of the contact |

#### Query Parameters

| Name          | Type    | Description                                                                                                                                                                                                                                                                                                             |
| ------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| with\_related | boolean | <p>Can be either <code>1</code> or <code>0</code>. Default is <code>1</code>. When passed, information about the related records to the requested record are also returned, in a <code>'related'</code> object.<br>If you don't need the related records, set this to <code>0</code> for a performance improvement.</p> |

#### Headers

| Name          | Type   | Description        |
| ------------- | ------ | ------------------ |
| Authorization | string | Your access token. |

{% tabs %}
{% tab title="200 Update successfully retrieved." %}

```javascript
{
    "id": 1241
    "name": "Adam Adamson",
    "first_name": "Adam",
    "last_name": "Adamson",
    "email_address": "adam@adamson.com",
    "primary_company": 1237,
    "title": "CEO",
    "assigned_user": 1231,
    ...
}
```

{% endtab %}

{% tab title="404 Could not find a post matching the provided ID." %}

```javascript
{
    "message": "Post not found."
}
```

{% endtab %}
{% endtabs %}

#### Example Usage

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

```javascript
var settings = {
  "url": "https://api.tiny.plus/v2/updates/{{id}}",
  "method": "GET",
  "headers": {
    "Authorization": "{{user_access_token}}"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.tiny.plus/v2/updates/{{id}}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => false,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: {{user_access_token}}"
  ),
));

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

curl_close($curl);

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

{% endtab %}
{% endtabs %}

## List Posts

<mark style="color:blue;">`GET`</mark> `https://api.tiny.plus/v2/updates`

This endpoint allows you to get a paginated list of News Feed Posts, optionally filtered by criteria.

#### Query Parameters

| Name            | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| {{field\_name}} | string  | <p>You can provide any <code>{{field\_name}}</code> listed in the <strong>Fields Reference</strong> as a filter to the projects returned. <br><br>You can also provide a minimum or maximum value by prepending a <code><</code> or <code>></code> before your value, which is useful for returning records modified or created after a certain datetime stamp.<br><br><em>To return all posts made by user 1232:</em><br><code>/updates/?created\_user=1232</code><br><br><em>To return all posts made after a date:</em><br><code>/updates/?created\_date=>2020-01-01 14:00:00</code></p> |
| me              | boolean | If this key is present, it will limit the  results to only records where the user associated with the API key is the `assigned_user`.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| subscribed      | string  | Similar to the `me` parameter, this parameter when present returns all records for the user associated with the API key is the `assigned_user`, or is in the Related Team Members, *or is a subscriber to the record.*                                                                                                                                                                                                                                                                                                                                                                      |
| limit           | number  | Used for pagination. Limit is the number of records to return from the full resultset. The default is `15`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| start           | number  | Used for pagination. Set this value to the cursor position into the total resultset to return this time. eg. to receive the 101st to the 115th record, set this to `100` and the limit parameter to `15`.  Default is `0`.                                                                                                                                                                                                                                                                                                                                                                  |
| sort            | string  | <p>Provide a field name and optionally a direction separated by a space to sort the returned results. For example, <code>modified\_date desc</code> to return the most recently modified records. The two directions available are <code>asc</code> and <code>desc</code>. If you do not provide a direction <code>asc</code> is assumed. You can sort by any Number, Date or Text field in the <strong>Fields Reference</strong> below.<br>The default sort for Posts is <code>id desc</code>.</p>                                                                                         |
| return\_format  | string  | <p>Can be either <code>array</code> or <code>object</code>.  The default is <code>object</code>.<br>When set to <code>array</code>, you will receive a simple JSON array of records objects. When set to <code>object</code>, you will receive a JSON object containing record objects as properties keyed by each record's ID. </p>                                                                                                                                                                                                                                                        |

#### Headers

| Name          | Type   | Description        |
| ------------- | ------ | ------------------ |
| Authorization | string | Your access token. |

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

```
```

{% endtab %}
{% endtabs %}

#### Example Usage

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

```javascript
var settings = {
  "url": "https://api.tiny.plus/v2/updates?me&return_format=array",
  "method": "GET",
  "headers": {
    "Authorization": "{{user_access_token}}"
  }
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
```

{% endtab %}
{% endtabs %}

## Create a Post

<mark style="color:green;">`POST`</mark> `https://api.tiny.plus/v2/updates`

You can create a new news feed post with this endpoint. &#x20;

#### Query Parameters

| Name           | Type    | Description                                                                         |
| -------------- | ------- | ----------------------------------------------------------------------------------- |
| return\_record | boolean | Add this parameter to get a copy of the newly created record. Save yourself a call! |

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Accepts       | string | Use `application/json` |
| Content-Type  | string | Use `application/json` |
| Authorization | string | Your access token.     |

#### Request Body

| Name          | Type    | Description                                                                                                                                                                                                        |
| ------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| description   | string  | The content of the new post you want to make. Do not include HTML.                                                                                                                                                 |
| related\_id   | integer | A single record id of a project, company, contact or other tiny+ record which this post relates to.                                                                                                                |
| extra\_ids    | string  | <p>Pass optional extra ids, separated by a comma (,) of any supported record type(s) to also relate the post to these records. You may pass up to 5 record ids in this way.<br>eg: <code>2555,2264,2222</code></p> |
| created\_user | integer | The user id who should be attributed to this post. The default is the user related to the access token.                                                                                                            |

{% tabs %}
{% tab title="200 A JSON object is returned with your new tiny+ record ID." %}

```
{
    id: [your new ID]
}
```

{% endtab %}

{% tab title="400 If there was a problem adding the record, you'll receive a 400 response." %}

```
{
    error: 'Error adding the record.'
}
```

{% endtab %}

{% tab title="403 If you do not have permission to add the record, you'll receive a 403 response." %}

```
```

{% endtab %}
{% endtabs %}

## Delete a Post

<mark style="color:red;">`DELETE`</mark> `https://api.tiny.plus/v2/updates/{{id}}`

Delete a News Feed Post.

#### Path Parameters

| Name | Type   | Description     |
| ---- | ------ | --------------- |
| id   | string | ID of the post. |

#### Headers

| Name          | Type   | Description        |
| ------------- | ------ | ------------------ |
| Authorization | string | Your access token. |

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

```
```

{% endtab %}
{% endtabs %}

## Posts Field Reference

| Field                 |                      Type                     | Details                                                                                                                | Permission |
| --------------------- | :-------------------------------------------: | ---------------------------------------------------------------------------------------------------------------------- | :--------: |
| id                    |                     Number                    | Unique record identifier.                                                                                              |  Read-only |
| name                  |             Auto-generated String             | This is an auto-generated shortening of the start of the description field, with all non-printable characters removed. |    Full    |
| description           | <p>String</p><p><strong>REQUIRED</strong></p> | The body of the post.                                                                                                  |    Full    |
| description\_HTML     |                     String                    | The description field but with certain HTML elements intact, such as embedded videos.                                  |  Read-only |
| created\_date         |          String (YYYY-MM-DD hh:mm:ss)         | Date record was first created.                                                                                         |  Read-only |
| modified\_date        |          String (YYYY-MM-DD hh:mm:ss)         | Date record was last modified.                                                                                         |  Read-only |
| created\_user         |                     Number                    | ID of user who made the record.                                                                                        |  Read-only |
| modified\_user        |                     Number                    | ID of user who last edited the record.                                                                                 |  Read-only |
| assigned\_user        |                     Number                    | ID of assigned user.                                                                                                   |    Full    |
| record\_url           |                     String                    | The fully qualified URI of the record.                                                                                 |  Read-only |
| created\_user\_record |                     Object                    | An object containing details about the created\_user.                                                                  |  Read-only |
| attached              |                     Object                    | An array of objects containing all the related records attached to this post.                                          |  Read-only |
| images                |                     Object                    | An array of objects containing details of any images associated with this post.                                        |  Read-only |
| social                |                     Object                    | Refer below.                                                                                                           |  Read-only |
| broadcast             |                    Boolean                    | Whether to show this post in the main tiny+ news feed. Either `true` or `false`. Default is `true`.                    |    Full    |
