REST API Reference

Updated: May 11, 2025 API Version: v1

Introduction

The MyAppAPI REST API follows REST principles and uses standard HTTP methods to create, read, update, and delete resources. Our API is designed to be intuitive, consistent, and developer-friendly, making it easy to integrate with your applications.

This documentation provides a comprehensive reference for all available REST endpoints, request/response formats, authentication methods, and common patterns for efficient API usage. We've included code examples in multiple programming languages to help you quickly implement API integrations.

Alternative API Options

In addition to our REST API, we offer a GraphQL API for flexible data fetching and a WebSocket API for real-time functionality. Choose the approach that best fits your application needs.

Base URL & Versioning

All API requests should be made to the following base URL:

https://api.myappapi.com/v1/

Our API is versioned to ensure backward compatibility as we add new features. The current version is v1. When we release new major versions, we'll maintain support for previous versions according to our API lifecycle policy.

Important

Always include the API version in your requests. Omitting the version may result in unexpected behavior as we route unversioned requests to the latest API version, which may introduce breaking changes.

Regional Endpoints

For applications requiring data residency or reduced latency, we offer regional API endpoints:

Region Base URL
United States (Default) https://api.myappapi.com/v1/
European Union https://eu.api.myappapi.com/v1/
Asia-Pacific https://ap.api.myappapi.com/v1/

Authentication

MyAppAPI offers multiple authentication methods to secure your API requests. Choose the method that best fits your security requirements and development workflow.

API Keys

The simplest authentication method is using API keys. Include your API key in the HTTP header of every request:

curl -X GET "https://api.myappapi.com/v1/users" \
  -H "X-API-Key: your_api_key_here"
const axios = require('axios');

const response = await axios.get('https://api.myappapi.com/v1/users', {
  headers: {
    'X-API-Key': 'your_api_key_here'
  }
});
import requests

headers = {
    'X-API-Key': 'your_api_key_here'
}

response = requests.get('https://api.myappapi.com/v1/users', headers=headers)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.myappapi.com/v1/users"))
    .header("X-API-Key", "your_api_key_here")
    .build();

HttpResponse response = client.send(request, 
    HttpResponse.BodyHandlers.ofString());

API Key Security

Your API key carries many privileges, so be sure to keep it secure! Do not share your API key in publicly accessible areas such as GitHub, client-side code, or in requests to our API directly from your browser.

OAuth 2.0

For applications requiring more advanced security or user-context operations, we support OAuth 2.0 authentication. Send the bearer token in the Authorization header:

curl -X GET "https://api.myappapi.com/v1/users/me" \
  -H "Authorization: Bearer oauth_token_here"
const axios = require('axios');

const response = await axios.get('https://api.myappapi.com/v1/users/me', {
  headers: {
    'Authorization': 'Bearer oauth_token_here'
  }
});
import requests

headers = {
    'Authorization': 'Bearer oauth_token_here'
}

response = requests.get('https://api.myappapi.com/v1/users/me', headers=headers)

For complete details on implementing OAuth 2.0 authentication, including obtaining tokens and handling refresh flows, see our Authentication Guide.

JWT Authentication

For advanced authentication scenarios, we also support JSON Web Token (JWT) authentication. See our JWT Authentication Guide for implementation details.

Request Format

The MyAppAPI REST API accepts data in JSON format for request bodies. When sending data to the API, use the following guidelines:

HTTP Methods

Our API uses standard HTTP methods to perform operations on resources:

Method Description
GET Retrieve resources
POST Create new resources
PUT Update resources (replace entire resource)
PATCH Partially update resources (modify specific fields)
DELETE Remove resources

Headers

Include the following headers with your requests:

Header Description Required
Content-Type Set to application/json for request bodies Yes (for requests with bodies)
Accept Set to application/json to receive JSON responses Recommended
X-API-Key or Authorization Authentication credentials Yes
Idempotency-Key Unique key for idempotent operations (recommended for POST, PUT, PATCH) No (but recommended)

Request Body Example

When creating or updating resources, include the data in JSON format in the request body:

{
  "name": "New Project",
  "description": "This is a sample project created via API",
  "visibility": "private",
  "settings": {
    "enableNotifications": true,
    "defaultView": "kanban"
  },
  "tags": ["development", "api-test"]
}
curl -X POST "https://api.myappapi.com/v1/projects" \
  -H "X-API-Key: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "New Project",
    "description": "This is a sample project created via API",
    "visibility": "private",
    "settings": {
      "enableNotifications": true,
      "defaultView": "kanban"
    },
    "tags": ["development", "api-test"]
  }'

Query Parameters

For GET requests, use query parameters to filter, paginate, and sort results:

GET https://api.myappapi.com/v1/projects?status=active&limit=10&sort=created_at:desc

URL Encoding

Remember to URL-encode query parameter values that contain special characters. Most HTTP client libraries handle this automatically, but it's important to be aware of this requirement when constructing URLs manually.

Response Format

All responses from the MyAppAPI REST API are returned in JSON format. We use consistent response structures across all endpoints to make integration straightforward and predictable.

Successful Responses

Successful responses include an HTTP status code in the 2xx range and a JSON body with the requested data. The exact structure depends on the type of request:

Single Resource Response

{
  "data": {
    "id": "proj_12345",
    "name": "My Project",
    "description": "This is a sample project",
    "visibility": "private",
    "created_at": "2025-05-11T12:34:56.789Z",
    "updated_at": "2025-05-11T12:34:56.789Z",
    "settings": {
      "enableNotifications": true,
      "defaultView": "kanban"
    },
    "tags": ["development", "api-test"]
  },
  "meta": {
    "request_id": "req_abcdef123456"
  }
}

Collection Response

{
  "data": [
    {
      "id": "proj_12345",
      "name": "My Project",
      "description": "This is a sample project",
      "visibility": "private",
      "created_at": "2025-05-11T12:34:56.789Z",
      "updated_at": "2025-05-11T12:34:56.789Z"
    },
    {
      "id": "proj_67890",
      "name": "Another Project",
      "description": "This is another sample project",
      "visibility": "public",
      "created_at": "2025-05-10T10:20:30.456Z",
      "updated_at": "2025-05-10T10:20:30.456Z"
    }
  ],
  "meta": {
    "page": 1,
    "limit": 10,
    "total": 42,
    "has_more": true,
    "request_id": "req_abcdef123456"
  },
  "links": {
    "self": "https://api.myappapi.com/v1/projects?page=1&limit=10",
    "next": "https://api.myappapi.com/v1/projects?page=2&limit=10",
    "prev": null
  }
}

Create or Update Response

Responses for resource creation (POST) or updates (PUT/PATCH) return the created or updated resource:

{
  "data": {
    "id": "proj_12345",
    "name": "Updated Project Name",
    "description": "This project has been updated via API",
    "visibility": "private",
    "created_at": "2025-05-11T12:34:56.789Z",
    "updated_at": "2025-05-11T14:20:30.123Z",
    "settings": {
      "enableNotifications": true,
      "defaultView": "list"
    },
    "tags": ["development", "api-test", "updated"]
  },
  "meta": {
    "request_id": "req_abcdef123456"
  }
}

Delete Response

Successful delete operations return an HTTP 204 No Content status with no response body.

HTTP Status Codes

We use standard HTTP status codes to indicate the success or failure of API requests:

Status Code Description
200 OK The request was successful
201 Created The resource was successfully created
204 No Content The request was successful, but there's no content to return (e.g., for DELETE requests)
400 Bad Request The request was invalid or cannot be processed
401 Unauthorized Authentication credentials are missing or invalid
403 Forbidden The authenticated user doesn't have permission to access the requested resource
404 Not Found The requested resource doesn't exist
409 Conflict The request conflicts with the current state of the resource
422 Unprocessable Entity The request was well-formed but contains semantic errors
429 Too Many Requests Rate limit exceeded
500 Internal Server Error An unexpected error occurred on the server

Rate Limits

To ensure fair usage and maintain service stability, we implement rate limits on API requests. Rate limits vary based on your subscription plan:

Plan Rate Limit Burst Limit
Free 60 requests per minute 100 requests per minute
Professional 300 requests per minute 500 requests per minute
Business 1,000 requests per minute 1,500 requests per minute
Enterprise Custom limits Custom limits

When you exceed your rate limit, you'll receive a 429 Too Many Requests response with information about when you can resume making requests.

Rate Limit Headers

Each API response includes headers to help you track your rate limit usage:

Header Description
X-RateLimit-Limit The maximum number of requests you can make per minute
X-RateLimit-Remaining The number of requests remaining in the current rate limit window
X-RateLimit-Reset The time at which the current rate limit window resets (Unix timestamp in seconds)

Best Practices for Rate Limits

  • Implement exponential backoff for retries when you receive a 429 response
  • Use bulk operations where available to reduce the number of API calls
  • Monitor your rate limit usage with the provided headers
  • Consider upgrading your plan if you consistently hit rate limits

Enterprise Rate Limits

Enterprise customers can request custom rate limits based on their specific needs. Contact your account manager or our sales team to discuss custom rate limit options.

Error Handling

When an error occurs, the API returns an appropriate HTTP status code along with a JSON response body containing error details to help you diagnose and resolve the issue.

Error Response Format

{
  "error": {
    "type": "validation_error",
    "message": "The request was invalid and cannot be processed",
    "code": "invalid_parameters",
    "request_id": "req_abcdef123456",
    "details": [
      {
        "field": "name",
        "message": "Name is required",
        "code": "missing_required_field"
      },
      {
        "field": "visibility",
        "message": "Visibility must be one of: private, team, public",
        "code": "invalid_enum_value"
      }
    ]
  }
}

Common Error Types

Error Type Description HTTP Status
authentication_error Authentication failed or credentials are invalid 401
authorization_error The authenticated user lacks permission for the requested action 403
validation_error The request data failed validation 400 or 422
not_found The requested resource doesn't exist 404
rate_limit_exceeded You've exceeded your rate limit 429
conflict The request conflicts with the current state of the resource 409
service_error An unexpected error occurred on the server 500

Handling Errors

Here's an example of how to handle API errors in your code:

async function createProject(projectData) {
  try {
    const response = await fetch('https://api.myappapi.com/v1/projects', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-API-Key': 'your_api_key_here'
      },
      body: JSON.stringify(projectData)
    });
    
    const data = await response.json();
    
    if (!response.ok) {
      // Handle error based on status code and error type
      const error = data.error;
      
      if (error.type === 'validation_error') {
        // Handle validation errors
        console.error('Validation error:', error.details);
        // Highlight form fields with errors
      } else if (error.type === 'rate_limit_exceeded') {
        // Implement exponential backoff and retry
        const resetTime = parseInt(response.headers.get('X-RateLimit-Reset'));
        const waitTime = resetTime - Math.floor(Date.now() / 1000);
        console.log(`Rate limit exceeded. Retry after ${waitTime} seconds.`);
      } else {
        // Handle other errors
        console.error(`Error ${response.status}: ${error.message}`);
      }
      
      return null;
    }
    
    return data.data;
  } catch (err) {
    console.error('Network or parsing error:', err);
    return null;
  }
}
import requests
import time

def create_project(project_data, api_key):
    try:
        headers = {
            'Content-Type': 'application/json',
            'X-API-Key': api_key
        }
        
        response = requests.post(
            'https://api.myappapi.com/v1/projects',
            headers=headers,
            json=project_data
        )
        
        # Parse the response
        data = response.json()
        
        # Check if the request was successful
        if response.status_code >= 400:
            error = data.get('error', {})
            error_type = error.get('type')
            
            if error_type == 'validation_error':
                # Handle validation errors
                print('Validation errors:')
                for detail in error.get('details', []):
                    print(f"  - {detail.get('field')}: {detail.get('message')}")
            elif error_type == 'rate_limit_exceeded':
                # Implement exponential backoff and retry
                reset_time = int(response.headers.get('X-RateLimit-Reset', 0))
                wait_time = max(0, reset_time - int(time.time()))
                print(f"Rate limit exceeded. Retry after {wait_time} seconds.")
            else:
                # Handle other errors
                print(f"Error {response.status_code}: {error.get('message')}")
            
            return None
        
        return data.get('data')
    except requests.exceptions.RequestException as e:
        print(f"Network error: {e}")
        return None
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public Project createProject(ProjectRequest projectData, String apiKey) {
    HttpClient client = HttpClient.newBuilder()
        .connectTimeout(Duration.ofSeconds(10))
        .build();
    
    Gson gson = new Gson();
    String requestBody = gson.toJson(projectData);
    
    try {
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.myappapi.com/v1/projects"))
            .header("Content-Type", "application/json")
            .header("X-API-Key", apiKey)
            .POST(HttpRequest.BodyPublishers.ofString(requestBody))
            .build();
        
        HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
        
        JsonObject jsonResponse = gson.fromJson(response.body(), JsonObject.class);
        
        if (response.statusCode() >= 400) {
            JsonObject error = jsonResponse.getAsJsonObject("error");
            String errorType = error.get("type").getAsString();
            String message = error.get("message").getAsString();
            
            if ("validation_error".equals(errorType)) {
                System.err.println("Validation error: " + message);
                // Process detailed validation errors
                error.getAsJsonArray("details").forEach(detail -> {
                    JsonObject detailObj = detail.getAsJsonObject();
                    System.err.println("  - " + detailObj.get("field").getAsString() + 
                                      ": " + detailObj.get("message").getAsString());
                });
            } else if ("rate_limit_exceeded".equals(errorType)) {
                String resetHeader = response.headers().firstValue("X-RateLimit-Reset").orElse("0");
                long resetTime = Long.parseLong(resetHeader);
                long waitTime = Math.max(0, resetTime - (System.currentTimeMillis() / 1000));
                System.err.println("Rate limit exceeded. Retry after " + waitTime + " seconds.");
            } else {
                System.err.println("Error " + response.statusCode() + ": " + message);
            }
            
            return null;
        }
        
        // Extract and return the project data
        JsonObject data = jsonResponse.getAsJsonObject("data");
        return gson.fromJson(data, Project.class);
    } catch (Exception e) {
        System.err.println("Network or parsing error: " + e.getMessage());
        return null;
    }
}

Request IDs for Support

Every API response includes a unique request_id in both successful and error responses. If you need assistance with an API issue, include this request ID when contacting our support team to help us quickly identify and troubleshoot the problem.

Pagination

For endpoints that return collections of resources, we provide pagination to allow you to efficiently work with large datasets.

Page-Based Pagination

By default, we use page-based pagination. Use the page and limit query parameters to control the pagination:

GET https://api.myappapi.com/v1/projects?page=2&limit=25

Pagination parameters:

Parameter Description Default Maximum
page The page number to retrieve 1 1000
limit The number of items per page 20 100

The response includes pagination metadata in the meta object and navigation links in the links object:

{
  "data": [ /* Array of resources */ ],
  "meta": {
    "page": 2,
    "limit": 25,
    "total": 142,
    "has_more": true,
    "request_id": "req_abcdef123456"
  },
  "links": {
    "self": "https://api.myappapi.com/v1/projects?page=2&limit=25",
    "next": "https://api.myappapi.com/v1/projects?page=3&limit=25",
    "prev": "https://api.myappapi.com/v1/projects?page=1&limit=25"
  }
}

Cursor-Based Pagination

For large datasets or real-time data, we offer cursor-based pagination. Use the after parameter with the cursor value from the previous response:

GET https://api.myappapi.com/v1/events?limit=50&after=evt_12345abcdef

The response includes a next_cursor in the metadata:

{
  "data": [ /* Array of resources */ ],
  "meta": {
    "limit": 50,
    "next_cursor": "evt_67890ghijkl",
    "has_more": true,
    "request_id": "req_abcdef123456"
  },
  "links": {
    "self": "https://api.myappapi.com/v1/events?limit=50&after=evt_12345abcdef",
    "next": "https://api.myappapi.com/v1/events?limit=50&after=evt_67890ghijkl"
  }
}

Best Practices for Pagination

  • Use the highest practical limit value to reduce the number of API calls
  • For real-time data or large datasets, prefer cursor-based pagination
  • Use the provided next and prev links for navigation rather than constructing URLs manually
  • Check the has_more flag to determine if more results are available

Filtering & Sorting

Many API endpoints support filtering and sorting to help you retrieve exactly the data you need.

Filtering

Use query parameters to filter resources based on their attributes:

GET https://api.myappapi.com/v1/projects?status=active&visibility=public&created_after=2025-01-01T00:00:00Z

Common filter operators:

Operator Description Example
Equality Filter by exact match status=active
_in Match any value in a list status_in=active,paused
_gt, _gte Greater than, Greater than or equal amount_gt=1000
_lt, _lte Less than, Less than or equal amount_lt=5000
_after, _before Date comparisons created_after=2025-01-01T00:00:00Z
_contains String contains search name_contains=api
_starts_with String starts with name_starts_with=test
_exists Field exists (not null) description_exists=true

Sorting

Use the sort parameter to specify the field and direction for sorting results:

GET https://api.myappapi.com/v1/projects?sort=created_at:desc

You can sort by multiple fields by separating them with commas:

GET https://api.myappapi.com/v1/projects?sort=status:asc,created_at:desc

Sort Direction

The sort direction can be asc (ascending) or desc (descending). If not specified, sorting defaults to ascending order.

Filtering & Sorting Metadata

The response metadata includes information about the applied filters and sort criteria:

{
  "data": [ /* Array of resources */ ],
  "meta": {
    "page": 1,
    "limit": 20,
    "total": 42,
    "has_more": true,
    "filters": {
      "status": "active",
      "visibility": "public",
      "created_after": "2025-01-01T00:00:00Z"
    },
    "sort": ["created_at:desc"],
    "request_id": "req_abcdef123456"
  },
  "links": {
    /* Pagination links */
  }
}

API Resources

The MyAppAPI REST API is organized around resources. Each resource has a set of endpoints for performing operations on that resource. Below is an overview of the primary resources available in our API.

Available Resources

Resource Description Documentation
Users Manage user accounts and profiles Users API
Projects Create and manage projects Projects API
Tasks Work with tasks within projects Tasks API
Webhooks Configure event notifications Webhooks API
Teams Manage teams and memberships Teams API
Files Upload, download, and manage files Files API
Comments Add and manage comments on resources Comments API
Events Access event history and activity logs Events API
Integrations Configure third-party service integrations Integrations API

Resource Endpoints Pattern

Each resource follows a consistent endpoint pattern:

Operation HTTP Method Endpoint
List resources GET /v1/{resource}
Create resource POST /v1/{resource}
Get resource GET /v1/{resource}/{id}
Update resource PUT or PATCH /v1/{resource}/{id}
Delete resource DELETE /v1/{resource}/{id}
Resource relationships GET /v1/{resource}/{id}/{relationship}
Resource actions POST /v1/{resource}/{id}/{action}

Example: Projects Resource

Here's a complete example of the Projects resource endpoints:

Operation HTTP Method Endpoint Description
List projects GET /v1/projects Retrieve all projects the user has access to
Create project POST /v1/projects Create a new project
Get project GET /v1/projects/{project_id} Retrieve a specific project by ID
Update project PATCH /v1/projects/{project_id} Update specific fields of a project
Replace project PUT /v1/projects/{project_id} Replace all fields of a project
Delete project DELETE /v1/projects/{project_id} Delete a project
List project tasks GET /v1/projects/{project_id}/tasks Retrieve all tasks in a project
Add task to project POST /v1/projects/{project_id}/tasks Create a new task in a project
List project members GET /v1/projects/{project_id}/members Retrieve all members of a project
Add member to project POST /v1/projects/{project_id}/members Add a member to a project
Archive project POST /v1/projects/{project_id}/archive Archive a project
Restore project POST /v1/projects/{project_id}/restore Restore an archived project
Clone project POST /v1/projects/{project_id}/clone Create a copy of an existing project

Detailed Resource Documentation

For complete details on each resource, including available fields, required parameters, and response examples, refer to the specific resource documentation linked in the table above.