Network API Endpoints

This document outlines the available API endpoints for interacting with the MS network services. All requests should be made using HTTPS.

User Authentication

POST /api/v1/auth/login

Authenticates a user and returns an access token.

POST /api/v1/auth/login

Request Body:

{
    "username": "string",
    "password": "string"
}

Response (200 OK):

{
    "token": "string",
    "expires_in": "integer (seconds)",
    "user_id": "string"
}

Response (401 Unauthorized):

{
    "error": "Invalid credentials"
}

POST /api/v1/auth/refresh

Refreshes an expired access token.

POST /api/v1/auth/refresh

Request Body:

{
    "refresh_token": "string"
}

Response (200 OK):

{
    "token": "string",
    "expires_in": "integer (seconds)"
}

User Profile

GET /api/v1/users/{userId}

Retrieves the profile information for a specific user.

GET /api/v1/users/{userId}

Path Parameters:

Name Type Description Required
userId string The unique identifier of the user. Yes

Headers:

Authorization: Bearer <access_token>

Response (200 OK):

{
    "id": "string",
    "username": "string",
    "email": "string",
    "first_name": "string",
    "last_name": "string",
    "created_at": "ISO8601 datetime"
}

Response (404 Not Found):

{
    "error": "User not found"
}

PUT /api/v1/users/{userId}

Updates the profile information for a specific user.

PUT /api/v1/users/{userId}

Path Parameters:

Name Type Description Required
userId string The unique identifier of the user. Yes

Headers:

Authorization: Bearer <access_token>

Request Body:

{
    "email": "string (optional)",
    "first_name": "string (optional)",
    "last_name": "string (optional)"
}

Response (200 OK):

{
    "message": "User profile updated successfully"
}

Resources

GET /api/v1/resources

Retrieves a list of available resources.

GET /api/v1/resources

Query Parameters:

Name Type Description Required
limit integer Maximum number of resources to return. No
offset integer Number of resources to skip. No
type string Filter resources by type (e.g., "document", "image"). No

Headers:

Authorization: Bearer <access_token>

Response (200 OK):

{
    "data": [
        {
            "id": "string",
            "name": "string",
            "type": "string",
            "url": "string (signed URL for access)",
            "created_at": "ISO8601 datetime"
        }
    ],
    "total": "integer",
    "limit": "integer",
    "offset": "integer"
}

Example Usage: Fetching User Profile

This example demonstrates how to fetch a user's profile using the API.

Request:

curl -X GET \
  https://api.ms.com/api/v1/users/user-abc-123 \
  -H "Authorization: Bearer your_access_token_here"
            
Response:

{
    "id": "user-abc-123",
    "username": "johndoe",
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "created_at": "2023-10-27T10:00:00Z"
}