> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # List short codes GET https://%7BYour_Space_Name%7D.signalwire.com/api/relay/rest/short_codes Lists the messaging Short Codes connected to your SignalWire project. These leased codes can send and receive high-volume messages through their configured handlers. Standard long-code phone numbers are available through [List phone numbers](/docs/apis/rest/phone-numbers/list-phone-numbers). Results are sorted by creation date, most recent first. #### Permissions The API token used to authenticate must have the following scope(s) enabled to make a successful request: _Numbers_. [Learn more about API scopes](/docs/platform/your-signalwire-api-space). Reference: https://signalwire.com/docs/apis/rest/short-codes/list-short-codes ## Authentication - `Authorization` header (basic auth, required) — SignalWire Basic Authentication using Project ID and API Token. The client sends HTTP requests with the Authorization header containing the word Basic followed by a space and a base64-encoded string of project_id:token. The project ID will be used as the username and the API token as the password. Example: ``` Authorization: Basic base64(project_id:token) ``` ## Request ### Query parameters - `filter_name` (string, optional) — Filter by name. Returns all short codes containing this value as a substring. - `filter_number` (string, optional) — Filter by number. Returns all short codes containing this value as a substring. - `page_number` (integer, optional, default: 0) — The page number to retrieve. - `page_size` (integer, optional, default: 50) — The number of results per page. - `page_token` (string, optional) — Token for cursor-based pagination. ## Response ### 200 The request has succeeded. - `links` (PaginationLinks, required) — Pagination links. - `data` (list of ShortCode, required) — List of short codes. ## Errors ### 400 Bad Request Error The request is invalid. - `error` (enum, required) - Allowed values: `Bad Request` ### 401 Unauthorized Error Access is unauthorized. - `error` (enum, required) - Allowed values: `Unauthorized` ### 500 Internal Server Error An internal server error occurred. - `error` (enum, required) - Allowed values: `Internal Server Error` ## Types ### PaginationLinks Pagination links for list responses. - `self` (string, required) — Link to the current page. - `first` (string, required) — Link to the first page. - `next` (string, optional) — Link to the next page. Only present when there are more results. - `prev` (string, optional) — Link to the previous page. Only present when not on the first page. ### ShortCode Short code model. - `id` (string, required) — The unique identifier of the short code. - `name` (string, required, nullable) — The name given to the short code. - `number` (string, required) — The short code number. - `capabilities` (list of enum, required) — The messaging capabilities of the short code. - Allowed values: `sms`, `mms` - `number_type` (enum, required) — The type of number (always 'shortcode'). - Allowed values: `shortcode` - `code_type` (enum, required) — The type of short code. - Allowed values: `vanity`, `random` - `country_code` (string, required) — The ISO 3166-1 alpha-2 country code. - `created_at` (string, required) — The date and time when the short code was created. - `updated_at` (string, required) — The date and time when the short code was last updated. - `next_billed_at` (string, required, nullable) — The date and time when the short code will next be billed. - `lease_duration` (string, required, nullable) — The lease duration of the short code (e.g., '12 months'). - `message_handler` (enum, required, nullable) — The message handler type for incoming messages. - Allowed values: `relay_context`, `laml_webhooks`, `laml_application` - `message_request_url` (string, required, nullable) — The URL to send message requests to when using laml_webhooks handler. - `message_request_method` (enum, required, nullable) — The HTTP method to use for message requests. - Allowed values: `GET`, `POST` - `message_fallback_url` (string, required, nullable) — The fallback URL for message requests. - `message_fallback_method` (enum, required, nullable) — The HTTP method to use for fallback requests. - Allowed values: `GET`, `POST` - `message_laml_application_id` (string, required, nullable) — The ID of the LāML application to handle messages when using laml_application handler. - `message_relay_context` (string, required, nullable) — The Relay context to use when using relay_context handler. ## Examples **Response** ```json { "links": { "self": "string", "first": "string", "next": "string", "prev": "string" }, "data": [ { "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "name": "My Short Code", "number": "12345", "capabilities": [ "sms" ], "number_type": "shortcode", "code_type": "vanity", "country_code": "US", "created_at": "2023-01-15T10:30:00Z", "updated_at": "2023-01-15T10:30:00Z", "next_billed_at": "2024-01-15T10:30:00Z", "lease_duration": "12 months", "message_handler": "relay_context", "message_request_url": "https://example.com/message", "message_request_method": "GET", "message_fallback_url": "https://example.com/fallback", "message_fallback_method": "GET", "message_laml_application_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "message_relay_context": "my-context" } ] } ``` **SDK Code** ```python import requests url = "https://{your_space_name}.signalwire.com/api/relay/rest/short_codes" response = requests.get(url, auth=("", "")) print(response.json()) ``` ```javascript const url = 'https://{your_space_name}.signalwire.com/api/relay/rest/short_codes'; const credentials = btoa(":"); const options = {method: 'GET', headers: {Authorization: `Basic ${credentials}`}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://{your_space_name}.signalwire.com/api/relay/rest/short_codes" req, _ := http.NewRequest("GET", url, nil) req.SetBasicAuth("", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://{your_space_name}.signalwire.com/api/relay/rest/short_codes") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request.basic_auth("", "") response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://{your_space_name}.signalwire.com/api/relay/rest/short_codes") .basicAuth("", "") .asString(); ``` ```php request('GET', 'https://{your_space_name}.signalwire.com/api/relay/rest/short_codes', [ 'headers' => [ ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` ```csharp using RestSharp; using RestSharp.Authenticators; var client = new RestClient("https://{your_space_name}.signalwire.com/api/relay/rest/short_codes"); client.Authenticator = new HttpBasicAuthenticator("", ""); var request = new RestRequest(Method.GET); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let credentials = Data(":".utf8).base64EncodedString() let headers = ["Authorization": "Basic \(credentials)"] let request = NSMutableURLRequest(url: NSURL(string: "https://{your_space_name}.signalwire.com/api/relay/rest/short_codes")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" 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() ```