# API Basics

## What is an API?

API stands for Application Programming Interface. APIs enable communication between two software components, typically a client and a server.  The application sending the request is the client, and the application sending the response is the server. When interacting with the Mobile Text Alerts API, the Mobile Text Alerts database is the server, and you send requests as the client.

There are different types of APIs, the MTA API is a REST API.

## REST APIs

REST stands for Representational State Transfer, a REST API is a way for software systems to communicate using HTTP. The main principle of REST APIs is statelessness, which means each request from a client to a server must contain all the information needed (no session stored on the server).  The server processes the request and returns the necessary data as plain text.

### HTTP Methods in REST

HTTP methods indicate the action the client would like to perform on a given resource. Examples of possible actions when calling the Mobile Text Alerts API: send a message, add/delete a subscriber, create a drip campaign, and many more.&#x20;

Each HTTP method is mapped to a specific operation and is included with every request to the API.&#x20;

#### HTTP Methods:

* `GET` - Retrieves data from the server.
  * *Example:* A `GET` request to the <mark style="color:blue;">`/subscribers`</mark> endpoint would return a list of all subscribers.
* `POST` - Sends data to the server to create something new.
  * *Example:* A `POST` request to the <mark style="color:blue;">`/send`</mark> endpoint would create a new message(s).
* `PATCH` - Updates existing data on the server.
  * *Example:* A `PATCH` request to the <mark style="color:blue;">`/threads/{threadId}/read`</mark> endpoint would update the thread specified with `{threadId}`as Read.
* `DELETE` - Removes existing data on the server.&#x20;
  * *Example:* A `DELETE` request to the  <mark style="color:blue;">`/groups/{groupId}`</mark> endpoint would remove the group specified with `{groupId}`.

### REST API Responses

After making a request to the API, it will return a response that contains the following information:

* [**HTTP status code**](/api-basics/error-response-codes.md#http-status-codes)- This three-digit code indicates the outcome of the request
  * *Example:* <mark style="color:green;">`200`</mark>&#x20;
* [**Response Headers**](/api-basics/request-response-headers.md#response-headers)- This provides metadata about the response.
  * *Example:* `Content-Type`*,* `Date`
* **Response Body/Payload**- This is the actual data content of the response.

  * *Example:*&#x20;

  ```json
  {
    "data": {
      "messageId": "uuid",
      "totalSent": 1,
      "totalFailedInternationalRecipients": 0
    },
    "message": "Message Sent to 1 Recipient."
  }
  ```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.mobile-text-alerts.com/api-basics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
