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) The question language will be detected automatically based on the title and description text. Providing a language explicitly is usually not necessary, and only helps in cases where the automatic language detection is not able to detect the language unambiguously (e.g. when title and description are in different languages).
category int (category code) null If this field is omitted, the question will be uncategorized.
tag_relations array of tag_relations - List of 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.
auto_tag_relations_excluded array of auto tag_relations to exclude List of tag relations that were suggested by the Starmind algorithm that were manually excluded. This prevents the tags from being added back again after a new tagging algorithm exist and the question gets re-tagged somewhere in the future.

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
    }
  ],
  "auto_tag_relations_excluded": [
    {
      "tag": "dead",
      "is_auto": true,
      "is_excluded": true
    }
  ],
  "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",
    "category": {
      "id": 123,
      "name": "A Category",
      "description": "Very interesting stuff.",
      "color": "#aa00ff",
      "translations": [
        {
          "language": "es",
          "name": "Una categoría",
          "description": "Cosas muy interesantes."
        }
      ]
    }
}


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

This endpoint is deprecated since 2.94.0. The endpoint will always return successfully with the question object, but no question image will be updated.

POST /questions/:ID/image

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"
}