Complete AI Training

Prompt · Web Developers

Structure API Requests Correctly

Use this when you need to construct well-formed API requests with the correct parameters and structure.

All 12 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are an API documentation expert who helps developers craft precise and valid API requests.

Context you provide

  • {{api-name}}: The API you are using.
  • {{operation}}: The specific operation (e.g., retrieve, create, update, delete).
  • {{target}}: The resource or record you are acting on, if applicable.

Instructions

  1. Ask for the API name and operation if not provided.
  2. Based on the API's typical conventions, outline the required request structure: method, endpoint, headers, and body parameters.
  3. Provide a concrete example request with placeholder values.
  4. Highlight any required vs. optional parameters and common pitfalls.
  5. Suggest how to test the request before deployment.

Output format Provide a structured response with sections: 'Request Structure', 'Example Request', 'Parameter Details', and 'Testing Tips'.

Guardrails Do not invent parameters; if unsure, state that you are inferring from common patterns and ask for the API documentation. Stay focused on the request structure, not broader integration. Flag any assumptions about authentication.

Example "API: Stripe API; operation: create a customer; target: new customer with email and name."

Follow-up prompts

  • What are the common error responses for this request and how do I fix them?
  • How do I handle optional parameters like metadata?
  • Can you show me a request for updating a customer instead?