Returns a list of all posts in the system. Requires valid authentication token.
All authentication strategies are supported:
JWT Token: Standard JWT with HS256 algorithm
Database Token: Custom token stored in user record
API Key: 40-character alphanumeric key
Devise Token Auth: Requires uid and client headers
Code | Description |
---|---|
401 | Unauthorized - Invalid or missing token |
403 | Forbidden - Token valid but insufficient permissions |
curl -X GET https://your-domain.com/api/v2/posts \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \ -H "Content-Type: application/json" Response (200): [ { "id": 1, "title": "Sample Post Title", "content": "This is the content of the post...", "author_id": 123, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z" }, { "id": 2, "title": "Another Post", "content": "Another post content...", "author_id": 456, "created_at": "2024-01-16T14:20:00Z", "updated_at": "2024-01-16T14:20:00Z" } ] Error Response (401): { "error": "Unauthorized" }
Header name | Description |
---|---|
Authorization required |
Bearer token for authentication |
uid optional |
User email (required for devise_token_auth) |
client optional |
Client ID (required for devise_token_auth) |
Returns a single post by its ID. Requires valid authentication token.
All authentication strategies are supported:
JWT Token: Standard JWT with HS256 algorithm
Database Token: Custom token stored in user record
API Key: 40-character alphanumeric key
Devise Token Auth: Requires uid and client headers
Code | Description |
---|---|
401 | Unauthorized - Invalid or missing token |
404 | Not Found - Post does not exist |
curl -X GET https://your-domain.com/api/v2/posts/123 -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." -H "Content-Type: application/json" Response (200): { "id": 123, "title": "Sample Post Title", "content": "This is the content of the post...", "author_id": 456, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-16T14:20:00Z" } Error Response (404): { "error": "Not Found" }
Param name | Description |
---|---|
id
required |
ID of the post Validations:
|
Header name | Description |
---|---|
Authorization required |
Bearer token for authentication |
uid optional |
User email (required for devise_token_auth) |
client optional |
Client ID (required for devise_token_auth) |
Search and filter posts using Ransack gem query parameters. Returns filtered results based on the provided search criteria.
Common predicates you can use:
_eq: Equal to
_cont: Contains (case insensitive)
_start: Starts with
_end: Ends with
_gt: Greater than
_gteq: Greater than or equal to
_lt: Less than
_lteq: Less than or equal to
_in: In array
_null: Is null
_not_null: Is not null
Use q parameter for sorting:
Search by title: ?q=rails
Search by author: ?q=123
Date range: ?q=2024-01-01&q=2024-12-31
Code | Description |
---|---|
401 | Unauthorized - Invalid or missing token |
422 | Unprocessable Entity - Invalid search parameters |
# Simple title search curl -X GET "https://your-domain.com/api/v2/posts/search?q[title_cont]=rails" \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \ -H "Content-Type: application/json" # Complex search with multiple filters curl -X GET "https://your-domain.com/api/v2/posts/search?q[title_cont]=guide&q[author_id_eq]=123&q[created_at_gteq]=2024-01-01&q[s]=created_at%20desc" \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \ -H "Content-Type: application/json" # Search multiple authors curl -X GET "https://your-domain.com/api/v2/posts/search?q[author_id_in][]=1&q[author_id_in][]=2&q[s]=title%20asc" \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \ -H "Content-Type: application/json" Success Response (200): [ { "id": 1, "title": "Rails Guide", "content": "A comprehensive rails guide...", "author_id": 123, "created_at": "2024-01-15T10:30:00Z", "updated_at": "2024-01-15T10:30:00Z" } ] Empty Results (200): [] Error Response (401): { "error": "Unauthorized" }
Param name | Description |
---|---|
q
optional |
Ransack query parameters for filtering and sorting posts Validations:
|
q[title_cont]
optional |
Title contains text (case insensitive) Validations:
|
q[title_eq]
optional |
Title equals exact text Validations:
|
q[title_start]
optional |
Title starts with text Validations:
|
q[title_end]
optional |
Title ends with text Validations:
|
q[content_cont]
optional |
Content contains text Validations:
|
q[author_id_eq]
optional |
Author ID equals Validations:
|
q[author_id_in]
optional |
Author ID in list Validations:
|
q[created_at_gteq]
optional |
Created at greater than or equal to date (YYYY-MM-DD) Validations:
|
q[created_at_lteq]
optional |
Created at less than or equal to date (YYYY-MM-DD) Validations:
|
q[created_at_gt]
optional |
Created at greater than date Validations:
|
q[created_at_lt]
optional |
Created at less than date Validations:
|
q[updated_at_gteq]
optional |
Updated at greater than or equal to date Validations:
|
q[updated_at_lteq]
optional |
Updated at less than or equal to date Validations:
|
q[id_eq]
optional |
Post ID equals Validations:
|
q[id_gt]
optional |
Post ID greater than Validations:
|
q[id_lt]
optional |
Post ID less than Validations:
|
q[id_in]
optional |
Post ID in list Validations:
|
q[s]
optional |
Sort by field and direction (e.g., “created_at desc”, “title asc”) Validations:
|
Header name | Description |
---|---|
Authorization required |
Bearer token for authentication |
uid optional |
User email (required for devise_token_auth) |
client optional |
Client ID (required for devise_token_auth) |
Code | Description |
---|---|
401 | Unauthorized (missing or invalid secret) |
422 | Validation errors |
503 | Receiving disabled by admin settings |
Request: POST /api/v2/webhooks/posts Headers: { "X-Webhook-Secret": "<secret>" } Body: { "title": "Example from Webhook", "content": "Hello from an external system", "post_type": "idea", "user_id": 1, "tags": ["integration", "external"] } Success (201): { "id": 42, "url": "https://needpedia.org/posts/42" }
Param name | Description |
---|---|
title
required |
Post title Validations:
|
content
optional |
Post content (text or HTML) Validations:
|
post_type
optional |
Type of the post (e.g., idea, problem, note) Validations:
|
user_id
required |
User ID for the post creator Validations:
|
subject_id
optional |
Optional subject ID Validations:
|
problem_id
optional |
Optional problem ID Validations:
|
lat
optional |
Latitude Validations:
|
long
optional |
Longitude Validations:
|
posted_to_id
optional |
Destination/posted_to ID Validations:
|
geo_maxing
optional |
Geo-maxing flag Validations:
|
group_id
optional |
Group ID Validations:
|
tags
optional |
List of tags Validations:
|
resource_tags
optional |
List of resource tags Validations:
|
created_at
optional |
ISO8601 timestamp to override creation time Validations:
|
updated_at
optional |
ISO8601 timestamp to override updated time Validations:
|
Header name | Description |
---|---|
X-Webhook-Secret required |
Shared secret for authentication |