{
 "schema": "aiblocks-page/1",
 "id": "build-first-api-endpoint-builder-prompt",
 "type": "prompt",
 "name": "API endpoint development brief writer",
 "summary": "Build your first API endpoint. Paste one prompt into Claude Code to make two small Next.js routes and learn how a server works.",
 "headline": "API endpoint development brief writer",
 "subhead": "Paste one prompt into Claude Code. It builds two small API routes in your Next.js project, a GET ping and a POST echo, then explains each step in plain English. A second prompt briefs your own first endpoint before any code is written.",
 "job": {
  "id": "build-software",
  "name": "Build and ship software"
 },
 "level": "beginner",
 "thinking": "medium",
 "tested": true,
 "updated": "2026-11-03",
 "first_published": "2026-10-25",
 "inputs": [
  {
   "type": "codebase",
   "required": true,
   "label": "Codebase",
   "what": "a project's code, in a folder or repo the AI can open"
  }
 ],
 "outputs": [
  {
   "type": "code_change",
   "required": true,
   "label": "Code change",
   "what": "a change to the code, with what it fixes and how it was checked"
  }
 ],
 "you_give": [
  "A Next.js project that uses the App Router, open in your coding AI",
  "Node.js and npm installed on your computer",
  "Claude Code or a similar coding AI that can edit your project files",
  "What your own first endpoint should do, in one or two sentences (optional)"
 ],
 "you_get": [
  "A GET ping route that returns the time and a status message",
  "A POST echo route that sends your data back and replies with clear errors for bad input",
  "A plain-English explanation of what happens when each route is called",
  "A list of every file the AI created or changed",
  "Test steps for Mac, Linux and Windows"
 ],
 "use_when": [
  "You use Claude Code or Cursor and want to see what an API endpoint really is.",
  "A developer or tool asks you for \"an endpoint\" and you want to know what that means.",
  "You plan to build a small tool for your store and want one working route to learn from.",
  "You are about to ask an AI for a real endpoint and want to practise the steps first."
 ],
 "skip_when": [
  "You want to test endpoints you already have: use the API test suite builder.",
  "Your app is a mobile app that needs a server: use the Expo API route builder.",
  "You want a Slack bot, not a web route: use the Slack bot build brief writer.",
  "You do not have a Next.js project with an app folder and Node.js installed: set those up first, or ask your AI which steps change for your stack."
 ],
 "output_sample": {
  "input": [
   "A Next.js project that uses the App Router",
   "Node.js and npm installed",
   "Claude Code or a similar coding AI",
   "A sentence on what your own first endpoint should do (optional)"
  ],
  "prerequisites": [
   "A paid Claude plan or an Anthropic API account for Claude Code"
  ],
  "output": [
   {
    "name": "ping route",
    "contains": "A GET route at app/api/ping that returns a status, the current time and a short message."
   },
   {
    "name": "echo route",
    "contains": "A POST route at app/api/echo that returns your data, with 400 and 413 replies for bad input."
   },
   {
    "name": "Plain-English explanation",
    "contains": "What happens on each call, what localhost and 3000 mean, and why the files sit where they do."
   },
   {
    "name": "File list",
    "contains": "Every file created or changed. No packages are installed and nothing is deployed."
   },
   {
    "name": "Own-endpoint brief",
    "contains": "The request checks, error replies, needs and tests for your own endpoint, ready for you to approve."
   }
  ]
 },
 "output_shape": "Check: <App Router found at app/ or src/app | not found, with what it saw>\n\nFiles created: app/api/ping/route.ts, app/api/echo/route.ts\nOther files changed: <list, or none>\n\nPlain-English explanation:\n1. What happens when you open /api/ping\n2. What happens when something posts to /api/echo\n3. What localhost and 3000 mean\n4. Why the files live in app/api\n5. What the 400 and 413 replies are for\n\nHow to test: <commands for your system>\n\nOptional brief for your own endpoint:\nPurpose | Request and checks | Success reply | Error replies | What it needs | Tests",
 "how_to_use": [
  "Open your Next.js project in Claude Code. Check that it has an app folder and that Node.js is installed.",
  "Copy the Part 1 prompt from the skill and paste it into Claude Code. Claude Code needs a paid Claude plan or an Anthropic API account.",
  "Read the explanation, then run npm run dev in your terminal. This starts the project on your own computer.",
  "Open localhost:3000/api/ping in your browser. Then test the echo route with the command in Part 2.",
  "Send the echo route text that is not valid JSON, and check you get the 400 error.",
  "When ready, paste the Part 3 prompt with your own endpoint idea. Read the brief and fix it before you say OK."
 ],
 "checks": [],
 "next": [
  {
   "name": "RoadRunner traffic test scenario writer",
   "url": "https://useaiblocks.com/skills/driving-test-scenario-writer",
   "why": "Build it"
  },
  {
   "name": "API test suite builder",
   "url": "https://useaiblocks.com/skills/api-test-suite-builder",
   "why": "API test suite builder"
  }
 ],
 "source": null,
 "credits": [],
 "files": [
  "references/worked-example.md"
 ],
 "links": {
  "page": "https://useaiblocks.com/prompts/build-first-api-endpoint-builder-prompt",
  "markdown": "https://useaiblocks.com/prompts/build-first-api-endpoint-builder-prompt.md",
  "json": "https://useaiblocks.com/prompts/build-first-api-endpoint-builder-prompt.json",
  "instructions": "https://useaiblocks.com/skills/build-first-api-endpoint-builder-prompt/SKILL.md",
  "download": "https://useaiblocks.com/skills/build-first-api-endpoint-builder-prompt.zip",
  "api_item": "https://useaiblocks.com/api/v1/items/build-first-api-endpoint-builder-prompt",
  "api_document": "https://useaiblocks.com/api/v1/documents/prompt/build-first-api-endpoint-builder-prompt",
  "mcp": "https://useaiblocks.com/mcp"
 }
}
