SchoolApiV1
Add User to Product API Endpoint
Add User to Product API Endpoint
Overview
The Add User to Product API Endpoint allows you to associate a user with a specific product. This endpoint is part of the v1 API version and is accessible via the POST HTTP method. You can specify the user by their ID or email.
Endpoint
- URL:
https://codeline.app/api/v1/products/[productId]/users - Method:
POST
Headers
- Authorization: Include the bearer token in the
Authorizationheader. The token must be prefixed withBearer. - Content-Type:
application/json
Request Params
productId(string): The ID of the product.user(string): The user ID or email of the user to be added to the product.
JavaScript Example
Here is an example of how to call the API using JavaScript:
Response Type
The response from the API is a JSON object containing details about the user and product association. Here is a TypeScript type definition for the response:
Error Handling
- Ensure the bearer token is valid and included in the request headers.
- Handle any errors by checking the response status and logging appropriate messages.
This example demonstrates how to construct the request with the necessary headers and body, and handle the response. Adjust the productId, token, and user variables with your actual values to use this example in your application.