Generate code comments

Add documentation comments to supplied source code.

{
    "title": "Generate code comments",
    "description": "",
    "method": "POST",
    "baseUrl": "https://app.docuwriter.ai",
    "endpoint": "/api/generate-code-comments",
    "headers": [
        {
            "key": "Authorization",
            "value": "Bearer YOUR_API_TOKEN",
            "type": "string",
            "required": true
        },
        {
            "key": "Accept",
            "value": "application/json",
            "type": "string",
            "required": true
        },
        {
            "key": "Content-Type",
            "value": "application/json",
            "type": "string",
            "required": true
        }
    ],
    "queryParams": [],
    "pathParams": [],
    "bodyType": "json",
    "requestBody": "{\n  \"source_code\": \"export function add(a, b) { return a + b; }\",\n  \"filename\": \"add.js\"\n}",
    "formData": [],
    "rawBody": "",
    "responses": {
        "200": {
            "description": "HTTP 200: success: true; data.generation contains generated text; data.generation_id is the numeric saved ID; data.version_number and data.definitive_version_number identify version metadata. The response also includes data.filename, prefixed with commented-. Review the returned code before replacing the original. Illustrative JSON example; sample values are fictional. Some optional or additional resource fields may be omitted.",
            "body": "{\n  \"success\": true,\n  \"data\": {\n    \"generation\": \"/** Add two numbers. */\\nexport function add(a, b) { return a + b; }\",\n    \"generation_id\": 456,\n    \"version_number\": 1,\n    \"definitive_version_number\": 1,\n    \"filename\": \"commented-add.js\"\n  }\n}"
        },
        "401": {
            "description": "Missing or invalid account API token.Missing or invalid account API token. Example JSON response.",
            "body": "{\n  \"message\": \"Unauthenticated.\"\n}"
        },
        "400": {
            "description": "Example: supplied code exceeds the processing budget.",
            "body": "{\n  \"success\": false,\n  \"message\": \"The provided code is too large for processing. Please reduce the amount of code and try again.\"\n}"
        }
    }
}

Request fields

Field Requirement
source_code Required source_code: source-code string.
filename Required filename: filename string.
name Optional name: saved generation title, maximum 255 characters.

Usage notes

  • Generation is synchronous and may take time.
  • The account must satisfy the generator’s current plan/credit checks (403 if denied).
  • Invalid fields return 422; code exceeding the processing token budget returns 400; upstream or output failures can return 500.
  • There is no idempotency-key contract: inspect generation history after an uncertain timeout before retrying. Errors and retries.

API authentication.

Updated