# Getting Started ## Authentication API requests to [httpSMS](https://httpsms.com/) are authenticated using API keys in the `x-api-key` header. Any request that doesn't include an API key will return a `401 (Unauthorized)` response. You can get your API key from the dashboard at [https://httpsms.com/settings](https://httpsms.com/settings/) ## Install the Android App To send and receive SMS messages using your android phone, you will need to [download and install our android app](https://github.com/NdoleStudio/httpsms/releases/latest/download/HttpSms.apk) on your phone so it can be triggered to send an SMS message when you make a request to the HTTP SMS API. Android App 👉 ## Send an SMS To send an SMS message using an android phone, send an authenticated `POST` request to the [`https://api.httpsms.com/v1/messages/send`](https://api.httpsms.com/v1/messages/send) endpoint. ## Send an SMS message > Add a new SMS message to be sent by your Android phone ```json {"openapi":"3.1.1","info":{"title":"httpSMS API Reference","version":"521014b"},"servers":[{"url":"https://api.httpsms.com/v1"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","name":"x-api-Key","in":"header"}},"schemas":{"responses.MessageResponse":{"type":"object","required":["data","message","status"],"properties":{"data":{"$ref":"#/components/schemas/entities.Message"},"message":{"type":"string"},"status":{"type":"string"}}},"entities.Message":{"type":"object","required":["contact","content","created_at","encrypted","id","max_send_attempts","order_timestamp","owner","request_received_at","send_attempt_count","sim","status","type","updated_at","user_id"],"properties":{"contact":{"type":"string"},"content":{"type":"string"},"created_at":{"type":"string"},"delivered_at":{"type":"string"},"encrypted":{"type":"boolean"},"expired_at":{"type":"string"},"failed_at":{"type":"string"},"failure_reason":{"type":"string"},"id":{"type":"string"},"last_attempted_at":{"type":"string"},"max_send_attempts":{"type":"integer"},"order_timestamp":{"type":"string"},"owner":{"type":"string"},"received_at":{"type":"string"},"request_id":{"type":"string"},"request_received_at":{"type":"string"},"scheduled_at":{"type":"string"},"scheduled_send_time":{"type":"string"},"send_attempt_count":{"type":"integer"},"send_time":{"description":"SendDuration is the number of nanoseconds from when the request was received until when the mobile phone send the message","type":"integer"},"sent_at":{"type":"string"},"sim":{"description":"SIM is the SIM card to use to send the message\n* SMS1: use the SIM card in slot 1\n* SMS2: use the SIM card in slot 2\n* DEFAULT: used the default communication SIM card","allOf":[{"$ref":"#/components/schemas/entities.SIM"}]},"status":{"type":"string"},"type":{"type":"string"},"updated_at":{"type":"string"},"user_id":{"type":"string"}}},"entities.SIM":{"type":"string","enum":["SIM1","SIM2"]},"responses.BadRequest":{"type":"object","required":["data","message","status"],"properties":{"data":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"}}},"responses.Unauthorized":{"type":"object","required":["data","message","status"],"properties":{"data":{"type":"string"},"message":{"type":"string"},"status":{"type":"string"}}},"responses.UnprocessableEntity":{"type":"object","required":["data","message","status"],"properties":{"data":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"}}},"message":{"type":"string"},"status":{"type":"string"}}},"responses.InternalServerError":{"type":"object","required":["message","status"],"properties":{"message":{"type":"string"},"status":{"type":"string"}}},"requests.MessageSend":{"type":"object","required":["content","from","to"],"properties":{"content":{"type":"string"},"encrypted":{"description":"Encrypted is an optional parameter used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app","type":"boolean"},"from":{"type":"string"},"request_id":{"description":"RequestID is an optional parameter used to track a request from the client's perspective","type":"string"},"send_at":{"description":"SendAt is an optional parameter used to schedule a message to be sent in the future. The time is considered to be in your profile's local timezone and you can queue messages for up to 20 days (480 hours) in the future.","type":"string"},"to":{"type":"string"}}}}},"paths":{"/messages/send":{"post":{"description":"Add a new SMS message to be sent by your Android phone","tags":["Messages"],"summary":"Send an SMS message","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/responses.MessageResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/responses.BadRequest"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/responses.Unauthorized"}}}},"422":{"description":"Unprocessable Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/responses.UnprocessableEntity"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/responses.InternalServerError"}}}}},"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/requests.MessageSend"}}},"description":"Send message request payload","required":true}}}}} ``` You can also use the code samples below to send an SMS message using our API on your favorite programing language. {% tabs %} {% tab title="PHP" %} ```php // initialize guzzle client https://github.com/guzzle/guzzle $client = new GuzzleHttp\Client(); $apiKey = "Get API Key from https://httpsms.com/settings"; $res = $client->request('POST', 'https://api.httpsms.com/v1/messages/send', [ 'headers' => [ 'x-api-key' => $apiKey, ], 'json' => [ 'content' => 'This is a sample text message', 'from' => "+18005550199", 'to' => '+18005550100' ] ]); echo $res->getBody(); ``` {% endtab %} {% tab title="Javascript" %} ```javascript let apiKey = "Get API Key from https://httpsms.com/settings"; fetch('https://api.httpsms.com/v1/messages/send', { method: 'POST', headers: { 'x-api-key': apiKey, 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ "content": "This is a sample text message", "from": "+18005550199", "to": "+18005550100" }) }) .then(res => res.json()) .then((data) => console.log(data)); ``` {% endtab %} {% tab title="Python" %} ```python import requests import json api_key = "Get API Key from https://httpsms.com/settings" url = 'https://api.httpsms.com/v1/messages/send' headers = { 'x-api-key': api_key, 'Accept': 'application/json', 'Content-Type': 'application/json' } payload = { "content": "This is a sample text message", "from": "+18005550199", "to": "+18005550100" } response = requests.post(url, headers=headers, data=json.dumps(payload)) print(response.json()) ``` {% endtab %} {% tab title="curl" %} ```bash curl --location --request POST 'https://api.httpsms.com/v1/messages/send' \ --header 'x-api-key: Get API Key from https://httpsms.com/settings' \ --header 'Content-Type: application/json' \ --data-raw '{ "from": "+18005550199", "to": "+18005550100", "content": "This is a sample text message" }' ``` {% endtab %} {% tab title="Go" %} ```go import "github.com/NdoleStudio/httpsms-go" client := htpsms.New(htpsms.WithAPIKey(/* API Key from https://httpsms.com/settings */)) client.Messages.Send(context.Background(), &httpsms.MessageSendParams{ Content: "This is a sample text message", From: "+18005550199", To: "+18005550100", }) ``` {% endtab %} {% tab title="c-sharp" %} ```csharp var client = new HttpClient(); client.DefaultRequestHeaders.Add("x-api-key", ""/* Get API Key from https://httpsms.com/settings */); var response = await client.PostAsync( "https://api.httpsms.com/v1/messages/send", new StringContent( JsonSerializer.Serialize(new { from = "+18005550199", To = "+18005550100", Content = "This is a sample text message", }), Encoding.UTF8, "application/json" ) ); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` {% endtab %} {% tab title="Java" %} ```java var client = HttpClient.newHttpClient(); var apiKey = "Get API Key from https://httpsms.com/settings"; JSONObject request = new JSONObject(); request.put("content", "This is a sample text message"); request.put("from", "+18005550199") request.put("to", "+18005550100") // create a request var request = HttpRequest.newBuilder() .uri(URI.create("https://api.httpsms.com/v1/messages/send")) .header("accept", "application/json") .header("x-api-key", apiKey) .setEntity(new StringEntity(request.toString())) .POST() .build(); // use the client to send the request var response = client.send(request, new JsonBodyHandler<>(APOD.class)); // the response: System.out.println(response.body().get()); ``` {% endtab %} {% endtabs %} ## Install The best way to interact with the httpSMS API is by using one of our official SDK client libraries: {% tabs %} {% tab title="JavaScript" %} ```bash npm install httpsms # or yarn install httpsms ``` {% endtab %} {% tab title="Go" %} ```bash # install the go package using the "go get" command go get github.com/NdoleStudio/httpsms-go ``` {% endtab %} {% endtabs %}