Generate code optimization

Request improvements to supplied code.

{
    "title": "Generate code optimization",
    "description": "",
    "method": "POST",
    "baseUrl": "https://app.docuwriter.ai",
    "endpoint": "/api/generate-code-optimization",
    "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\": \"function sum(items) { return items.reduce((a, b) => a + b, 0); }\",\n  \"filename\": \"sum.js\",\n  \"additional_instructions\": \"Preserve the public function signature.\"\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. Output is proposed optimization content. It does not apply changes to your repository; benchmark and test the result before adopting it. Illustrative JSON example; sample values are fictional. Some optional or additional resource fields may be omitted.",
            "body": "{\n  \"success\": true,\n  \"data\": {\n    \"generation\": \"Use a Set for repeated membership checks.\",\n    \"generation_id\": 456,\n    \"version_number\": 1,\n    \"definitive_version_number\": 1\n  },\n  \"message\": \"Code optimization generated successfully\"\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.
additional_instructions Optional additional_instructions is a string for constraints or priorities.

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