# Like a post and other actions

`POST /post_actions.json`

Authentication: no security requirement declared for this operation.

Parameters:

- `Api-Key` (header, string, required)
  Type: string

- `Api-Username` (header, string, required)
  Type: string

Request body: application/json

Type: any

- `id` (required)
  Type: integer
  
  The ID of the post to perform the action on

- `post_action_type_id` (required)
  Type: integer
  
  The ID of the post action type (e.g., 2 for like)

- `flag_topic` (optional)
  Type: boolean
  
  Whether to flag the entire topic

Additional properties: false

Responses:

- 200: post updated

Content type: application/json

Type: any

- `id` (required)
  Type: integer
  
  The ID of the post

- `name` (required)
  Type: string
  
  The name of the post author

- `username` (required)
  Type: string
  
  The username of the post author

- `avatar_template` (required)
  Type: string
  
  Template for the author's avatar URL

- `created_at` (required)
  Type: string
  
  When the post was created

- `cooked` (required)
  Type: string
  
  The HTML content of the post

- `post_number` (required)
  Type: integer
  
  The post number within the topic

- `post_type` (required)
  Type: integer
  
  The type of post

- `posts_count` (required)
  Type: integer
  
  Total posts count for the user

- `updated_at` (required)
  Type: string
  
  When the post was last updated

- `reply_count` (required)
  Type: integer
  
  Number of replies to this post

- `reply_to_post_number` (required)
  Type: string; nullable
  
  Post number this post is replying to

- `quote_count` (required)
  Type: integer
  
  Number of times this post has been quoted

- `incoming_link_count` (required)
  Type: integer
  
  Number of incoming links to this post

- `reads` (required)
  Type: integer
  
  Number of reads

- `readers_count` (required)
  Type: integer
  
  Number of readers

- `score` (required)
  Type: number
  
  Post score

- `yours` (required)
  Type: boolean
  
  Whether this post belongs to the current user

- `topic_id` (required)
  Type: integer
  
  ID of the topic this post belongs to

- `topic_slug` (required)
  Type: string
  
  Slug of the topic this post belongs to

- `display_username` (required)
  Type: string
  
  Display username of the post author

- `primary_group_name` (required)
  Type: string; nullable
  
  Primary group name of the author

- `flair_name` (required)
  Type: string; nullable
  
  Flair name of the author

- `flair_url` (required)
  Type: string; nullable
  
  Flair URL of the author

- `flair_bg_color` (required)
  Type: string; nullable
  
  Flair background color of the author

- `flair_color` (required)
  Type: string; nullable
  
  Flair color of the author

- `flair_group_id` (required)
  Type: integer; nullable
  
  Flair group ID of the author

- `badges_granted` (required)
  Type: array
  
  Badges granted to the user

- `version` (required)
  Type: integer
  
  Version number of the post

- `can_edit` (required)
  Type: boolean
  
  Whether the current user can edit this post

- `can_delete` (required)
  Type: boolean
  
  Whether the current user can delete this post

- `can_recover` (required)
  Type: boolean
  
  Whether the current user can recover this post

- `can_see_hidden_post` (required)
  Type: boolean
  
  Whether the current user can see hidden posts

- `can_wiki` (required)
  Type: boolean
  
  Whether the current user can wiki this post

- `user_title` (required)
  Type: string; nullable
  
  Title of the post author

- `bookmarked` (required)
  Type: boolean
  
  Whether the post is bookmarked by the current user

- `actions_summary` (required)
  Type: Array<object>
  
  Summary of actions performed on this post
  
  Items:
    Type: object
    
    - `id` (optional)
      Type: integer
      
      ID of the action type (e.g., 2 for like)
    
    - `count` (optional)
      Type: integer
      
      Number of times this action has been performed
    
    - `acted` (optional)
      Type: boolean
      
      Whether the current user has performed this
      action
    
    - `can_undo` (optional)
      Type: boolean
      
      Whether the current user can undo this action
    
    - `can_act` (optional)
      Type: boolean
      
      Whether the current user can perform this action
    
    Additional properties: true

- `moderator` (required)
  Type: boolean
  
  Whether the post author is a moderator

- `admin` (required)
  Type: boolean
  
  Whether the post author is an admin

- `staff` (required)
  Type: boolean
  
  Whether the post author is staff

- `user_id` (required)
  Type: integer
  
  ID of the post author

- `hidden` (required)
  Type: boolean
  
  Whether the post is hidden

- `trust_level` (required)
  Type: integer
  
  Trust level of the post author

- `deleted_at` (required)
  Type: string; nullable
  
  When the post was deleted

- `user_deleted` (required)
  Type: boolean
  
  Whether the post was deleted by the user

- `edit_reason` (required)
  Type: string; nullable
  
  Reason for the last edit

- `can_view_edit_history` (required)
  Type: boolean
  
  Whether the current user can view edit history

- `wiki` (required)
  Type: boolean
  
  Whether this is a wiki post

- `reviewable_id` (required)
  Type: integer; nullable
  
  ID of the reviewable if this post is under review

- `reviewable_score_count` (required)
  Type: integer
  
  Number of reviewable scores

- `reviewable_score_pending_count` (required)
  Type: integer
  
  Number of pending reviewable scores

- `post_url` (required)
  Type: string
  
  URL of the post

Additional properties: true

## Examples

### cURL

```bash
curl -X POST 'https://discourse.example.com/post_actions.json' \
  -H 'Api-Key: string' \
  -H 'Api-Username: string' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "id": 0,
  "post_action_type_id": 0,
  "flag_topic": true
}'
```

### JavaScript

```javascript
const body = `{
  "id": 0,
  "post_action_type_id": 0,
  "flag_topic": true
}`;

const response = await fetch('https://discourse.example.com/post_actions.json', {
  method: 'POST',
  headers: {
    'Api-Key': 'string',
    'Api-Username': 'string',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "id": 0,
  "post_action_type_id": 0,
  "flag_topic": true
}'''

response = requests.post(
    'https://discourse.example.com/post_actions.json',
    data=body.encode('utf-8'),
    headers={
        'Api-Key': 'string',
        'Api-Username': 'string',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
