Question POST Resources


Create a Question

POST /questions
Parameter Type Default Required Description
title string - Between 10 and 100 characters.
description string (HTML + mentioning markup) null Unlimited length.
language string (language code) (automatically detected) If this field is omitted, the language will be detected automatically based on the title and description text.
category int (category code) null If this field is omitted, the question will be uncategorized.
tag_relations array of tag_relations - List of max 10 tag relations. A tag relation specifies the tag and whether it is automatically determined (e.g. via tag suggestions) or manually added by the user.

Payload

{
    "title": "Is Sherlock really dead?",
    "description": "<p>Post any information to 221B Baker Street, London.</p>",
    "tag_relations": [
        {"tag": "Sherlock Holmes", "is_auto": true},
        {"tag": "Moriarty", "is_auto": false}
    ],
    "category": 123
}

Be aware that this will not publish the question, it will be saved as a draft. It can be published with the question publish endpoint.

Tags should be specified by using the label, not the internal tag id. If a tag already exists with the same label (case-insensitive), then the API will automatically make the correct association with the existing tag when the question is published. To change the capitalization of an existing tag label, the tag PUT endpoint should be used. Specifying the same tag with different capitalizations or with different values for is_auto within a single request will cause a validation error.

Response

The endpoint will respond with the complete question object.

{
    "id": "47",
    "is_published": false,
    "published": null,
    "language": "en",
    "title": "Is Sherlock really dead?",
    "slug": "is-sherlock-holmes-really-dead",
    "description": "<p>Post any information to 221B Baker Street, London.</p>",
    "solution_count": 0,
    "view_count": 28,
    "image": "https://cdn.example.com/avatar/default/2d/1b84215e2f035a22f6fec213d3b1d9.jpg",
    "created": "2014-01-02T10:13:21.000Z",
    "updated": "2014-01-02T10:13:22.000Z",
    "content_updated": "2014-01-02T10:13:23.000Z",
    "tag_relations": [
        {
             "tag": "Sherlock Holmes",
             "is_auto": false
        },
        {
             "tag": "Moriarty",
             "is_auto": false
        }
    ],
    "attachments": "/questions/47/attachments",
    "upvote_count": 0,
    "category": "/categories/123"
}


Register a view

POST /questions/:ID/view

Response

This request does not have a body, and in case of success, a HTTP 200 OK without body will be sent.


Set question image

Uploads MUST be performed using the multipart/form-data Content-Type.

The image file is automatically resized to 96x96px and converted to grayscale.

POST /questions/:ID/image
Parameter Type Default Required Description
file file - Image file.

Response

{
    "id": "47",
    "is_published": false,
    "language": "en",
    "title": "Is Sherlock really dead?",
    "slug": "is-sherlock-holmes-really-dead",
    "description": "<p>Post any information to 221B Baker Street, London.</p>",
    "solution_count": 0,
    "image": "https://cdn.example.com/avatar/default/2d/1b84215e2f035a22f6fec213d3b1d9.jpg",
    "created": "2014-01-02T10:13:21.000Z",
    "updated": "2014-01-03T12:16:45.000Z",
    "content_updated": "2014-01-03T11:10:45.000Z",
    "tag_relations": [
        {
             "tag": "Sherlock Holmes",
             "is_auto": false
        },
        {
             "tag": "Moriarty",
             "is_auto": false
        }
    ],
    "attachments": "/questions/47/attachments",
    "category": "/categories/123"
}