App Services APIs

This document provides a comprehensive overview of the APIs available for interacting with Microsoft's App Services. These APIs enable you to manage and integrate your applications with various backend services.

Authentication & Authorization

GET /auth/userinfo

Retrieves information about the currently authenticated user.

Request

GET /auth/userinfo HTTP/1.1
Host: api.appservices.microsoft.com
Authorization: Bearer <access_token>

Response (200 OK)

{
  "userId": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
  "email": "user@example.com",
  "roles": ["admin", "developer"],
  "lastLogin": "2023-10-27T10:00:00Z"
}

POST /auth/login

Logs in a user and returns an access token.

Request

POST /auth/login HTTP/1.1
Host: api.appservices.microsoft.com
Content-Type: application/json

{
  "username": "user@example.com",
  "password": "secure_password"
}

Response (200 OK)

{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "expiresIn": 3600,
  "tokenType": "Bearer"
}

Data Management

GET /data/{resourceType}/{id}

Retrieves a specific data record by its ID.

Parameters

  • resourceType (string, required): The type of resource (e.g., 'products', 'orders').
  • id (string, required): The unique identifier of the record.

Response (200 OK)

{
  "id": "98765432-10fe-dcba-0987-654321fedcba",
  "name": "Premium Widget",
  "description": "A high-quality widget for all your needs.",
  "price": 29.99,
  "createdAt": "2023-10-26T09:00:00Z"
}

POST /data/{resourceType}

Creates a new data record.

Parameters

  • resourceType (string, required): The type of resource to create.

Request Body (example for 'products')

POST /data/products HTTP/1.1
Host: api.appservices.microsoft.com
Authorization: Bearer <access_token>
Content-Type: application/json

{
  "name": "Super Gadget",
  "description": "The latest and greatest gadget.",
  "price": 199.50
}

Response (201 Created)

{
  "id": "abcdef12-3456-7890-abcd-ef1234567890",
  "name": "Super Gadget",
  "description": "The latest and greatest gadget.",
  "price": 199.50,
  "createdAt": "2023-10-27T11:00:00Z"
}

PUT /data/{resourceType}/{id}

Updates an existing data record.

Parameters

  • resourceType (string, required): The type of resource.
  • id (string, required): The unique identifier of the record to update.

Request Body (example for 'products')

PUT /data/products/abcdef12-3456-7890-abcd-ef1234567890 HTTP/1.1
Host: api.appservices.microsoft.com
Authorization: Bearer <access_token>
Content-Type: application/json

{
  "description": "An improved version of the Super Gadget.",
  "price": 205.00
}

Response (200 OK)

{
  "id": "abcdef12-3456-7890-abcd-ef1234567890",
  "name": "Super Gadget",
  "description": "An improved version of the Super Gadget.",
  "price": 205.00,
  "updatedAt": "2023-10-27T12:00:00Z"
}

DELETE /data/{resourceType}/{id}

Deletes a data record.

Parameters

  • resourceType (string, required): The type of resource.
  • id (string, required): The unique identifier of the record to delete.

Response (204 No Content)

User Management

GET /users

Retrieves a list of users. Requires administrator privileges.

Query Parameters

  • status (string, optional): Filter by user status ('active', 'inactive').
  • page (integer, optional): Page number for pagination.
  • limit (integer, optional): Number of results per page.

Response (200 OK)

[{
  "userId": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
  "email": "user1@example.com",
  "status": "active"
}, {
  "userId": "b2c3d4e5-f6a7-8901-2345-67890abcdef1",
  "email": "user2@example.com",
  "status": "inactive"
}]

PATCH /users/{id}

Updates a user's profile or status. Requires administrator privileges.

Parameters

  • id (string, required): The unique identifier of the user.

Request Body (example)

PATCH /users/a1b2c3d4-e5f6-7890-1234-567890abcdef HTTP/1.1
Host: api.appservices.microsoft.com
Authorization: Bearer <admin_access_token>
Content-Type: application/json

{
  "status": "inactive",
  "roles": ["developer"]
}

Response (200 OK)

{
  "userId": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
  "email": "user1@example.com",
  "status": "inactive",
  "roles": ["developer"],
  "updatedAt": "2023-10-27T13:00:00Z"
}

Notifications

POST /notifications

Sends a notification to one or more users.

Request Body

POST /notifications HTTP/1.1
Host: api.appservices.microsoft.com
Authorization: Bearer <access_token>
Content-Type: application/json

{
  "recipients": ["user1@example.com", "user2@example.com"],
  "subject": "Important Update",
  "message": "Your subscription is expiring soon. Please renew.",
  "priority": "high"
}

Response (202 Accepted)

{
  "notificationId": "xyz789-abc123-def456",
  "status": "pending"
}

Storage

POST /storage/upload

Uploads a file to the App Services storage.

Request Body (multipart/form-data)

POST /storage/upload HTTP/1.1
Host: api.appservices.microsoft.com
Authorization: Bearer <access_token>
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="document.pdf"
Content-Type: application/pdf

[Binary data of the PDF file]
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Response (200 OK)

{
  "fileId": "doc-pdf-1234567890",
  "fileName": "document.pdf",
  "url": "https://storage.appservices.microsoft.com/files/doc-pdf-1234567890",
  "uploadedAt": "2023-10-27T14:00:00Z"
}

GET /storage/download/{fileId}

Downloads a file from App Services storage.

Parameters

  • fileId (string, required): The ID of the file to download.

Response (200 OK)

The response will be the binary content of the file with appropriate Content-Type header.

Reporting

GET /reports/usage

Generates a usage report for a specified period.

Query Parameters

  • startDate (date, required): The start date of the report (YYYY-MM-DD).
  • endDate (date, required): The end date of the report (YYYY-MM-DD).
  • format (string, optional): The format of the report ('json', 'csv'). Defaults to 'json'.

Response (200 OK - JSON format)

{
  "reportTitle": "Usage Report",
  "period": {
    "startDate": "2023-10-01",
    "endDate": "2023-10-26"
  },
  "summary": {
    "totalRequests": 15000,
    "uniqueUsers": 3500,
    "dataTransferredMB": 5120
  },
  "details": [
    {
      "date": "2023-10-01",
      "requests": 500,
      "users": 100
    },
    // ... more daily details
  ]
}