> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# GetSmsHistory

POST https://api.voximplant.com/platform_api/GetSmsHistory

Gets the history of sent and/or received SMS.

Allowed roles: `Owner`, `Admin`, `Developer`, `Supervisor`, `Accountant`, `CallsSMS`.

**Example request:** Get messages that had been sent to number 12345678222 starting from March 1, 2019. Number of resulting rows is limited to 2.

Reference: https://docs.voximplant.ai/api-reference/management-api/reference/sms/get-sms-history

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: management-api
  version: 1.0.0
paths:
  /GetSmsHistory:
    post:
      operationId: get-sms-history
      summary: GetSmsHistory
      description: >-
        Gets the history of sent and/or received SMS.


        Allowed roles: `Owner`, `Admin`, `Developer`, `Supervisor`,
        `Accountant`, `CallsSMS`.


        **Example request:** Get messages that had been sent to number
        12345678222 starting from March 1, 2019. Number of resulting rows is
        limited to 2.
      tags:
        - subpackage_sms
      parameters:
        - name: source_number
          in: query
          description: The source phone number
          required: false
          schema:
            type: string
        - name: destination_number
          in: query
          description: The destination phone number
          required: false
          schema:
            type: string
        - name: direction
          in: query
          description: >-
            Sent or received SMS. Possible values: 'IN', 'OUT', 'in, 'out'.
            Leave blank to get both incoming and outgoing messages
          required: false
          schema:
            type: string
        - name: count
          in: query
          description: >-
            Maximum number of resulting rows fetched. Must be not bigger than
            1000. If left blank, then the default value of 1000 is used
          required: false
          schema:
            type: integer
        - name: offset
          in: query
          description: The first **N** records are skipped in the output
          required: false
          schema:
            type: integer
        - name: from_date
          in: query
          description: >-
            Date from which to perform search. Format is 'yyyy-MM-dd HH:mm:ss',
            time zone is UTC
          required: false
          schema:
            type: string
        - name: to_date
          in: query
          description: >-
            Date until which to perform search. Format is 'yyyy-MM-dd HH:mm:ss',
            time zone is UTC
          required: false
          schema:
            type: string
        - name: output
          in: query
          description: >-
            The output format. The following values available: **json**,
            **csv**, **xls**. The default value is **json**
          required: false
          schema:
            type: string
            default: json
        - name: Authorization
          in: header
          description: >-
            Voximplant Management API uses signed JWT tokens generated from your
            service-account private key. Pass the token in the `Authorization`
            header as a Bearer value:


            ```

            Authorization: Bearer $VOXIMPLANT_TOKEN

            ```


            See [Authorization](/api-reference/management-api/authorization) for
            ready-to-copy snippets in bash, Python, Node.js and Go that turn
            your `credentials.json` into a token.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/sms_GetSmsHistory_Response_200'
servers:
  - url: https://api.voximplant.com/platform_api
components:
  schemas:
    SmsHistoryTypeSourceNumber:
      oneOf:
        - type: integer
        - type: string
      description: Number being called from
      title: SmsHistoryTypeSourceNumber
    SmsHistoryTypeDestinationNumber:
      oneOf:
        - type: integer
        - type: string
      description: Number being called to
      title: SmsHistoryTypeDestinationNumber
    SmsHistoryType:
      type: object
      properties:
        message_id:
          type: integer
          description: Message ID
        source_number:
          $ref: '#/components/schemas/SmsHistoryTypeSourceNumber'
          description: Number being called from
        destination_number:
          $ref: '#/components/schemas/SmsHistoryTypeDestinationNumber'
          description: Number being called to
        direction:
          type: string
          description: Incoming or outgoing message
        fragments:
          type: integer
          description: Number of fragments the initial message is divided into
        cost:
          type: number
          format: double
          description: Cost of the message
        status_id:
          type: string
          description: >-
            Status of the message. The possible values are: 1 — Success, 2 —
            Error, 3 — Waiting
        error_message:
          type: string
          description: Error message (if any)
        processed_date:
          type: string
          description: |-
            Date string as returned by the Management API.

            Date of message processing. The format is yyyy-MM-dd HH:mm:ss
        transaction_id:
          type: integer
          description: Id of the transaction for this message
        text:
          type: string
          description: Stored message text
      description: The [GetSmsHistory] function result.
      title: SmsHistoryType
    sms_GetSmsHistory_Response_200:
      type: object
      properties:
        result:
          type: array
          items:
            $ref: '#/components/schemas/SmsHistoryType'
        total_count:
          type: integer
          description: Total number of messages matching the query parameters
      title: sms_GetSmsHistory_Response_200
  securitySchemes:
    JwtAuth:
      type: http
      scheme: bearer
      description: >-
        Voximplant Management API uses signed JWT tokens generated from your
        service-account private key. Pass the token in the `Authorization`
        header as a Bearer value:


        ```

        Authorization: Bearer $VOXIMPLANT_TOKEN

        ```


        See [Authorization](/api-reference/management-api/authorization) for
        ready-to-copy snippets in bash, Python, Node.js and Go that turn your
        `credentials.json` into a token.

```

## SDK Code Examples

```python Example 1
import requests

url = "https://api.voximplant.com/platform_api/GetSmsHistory"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Example 1
const url = 'https://api.voximplant.com/platform_api/GetSmsHistory';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example 1
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.voximplant.com/platform_api/GetSmsHistory"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Example 1
require 'uri'
require 'net/http'

url = URI("https://api.voximplant.com/platform_api/GetSmsHistory")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java Example 1
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.voximplant.com/platform_api/GetSmsHistory")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Example 1
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.voximplant.com/platform_api/GetSmsHistory', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Example 1
using RestSharp;

var client = new RestClient("https://api.voximplant.com/platform_api/GetSmsHistory");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Example 1
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.voximplant.com/platform_api/GetSmsHistory")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```