Step 3.2: Add an Operation to Your Path
Operations define the actions your API can perform on a resource and are represented by HTTP verbs like GET
, POST
, PUT
, and DELETE
.
How to Add an Operation
-
Select the Path:
- From the list of paths you’ve created, select the path where you want to add an operation (e.g.,
/users
,/products
).
- From the list of paths you’ve created, select the path where you want to add an operation (e.g.,
-
Add an Operation:
- Click on the Add Operation button.
- Click on the Add Operation button.
-
Choose the HTTP Verb:
- Select the appropriate HTTP verb for the operation:
- GET: Retrieve data from the server.
- POST: Create a new resource.
- PUT: Update an existing resource.
- DELETE: Remove a resource.
- Select the appropriate HTTP verb for the operation:
-
Save the Operation:
- After selecting the HTTP verb, click Save to confirm the operation.
Examples of Operations for a User Resource:
HTTP Verb | Path | Description |
---|---|---|
GET | /users | Retrieve a list of all users. |
GET | /users/{id} | Retrieve a specific user by ID. |
POST | /users | Create a new user. |
PUT | /users/{id} | Update an existing user by ID. |
DELETE | /users/{id} | Delete a user by ID. |
With the operation added, your API is now ready to handle specific actions for the defined paths. The next step is to define the response that your API will return for each operation. Let’s continue!