GoliathDevelopersGet an API key
Reference/Phone Numbersgenerated from the gateway manifest

searchAvailablePhoneNumbers

Search Twilio for buyable phone numbers, optionally narrowed by areaCode.

POST/api/v1/callREADreadruns as the key's owner
View as Markdown

Search Twilio for buyable phone numbers, optionally narrowed by areaCode (a 3-digit US area code). Returns candidate numbers (E.164 phoneNumber plus locality/region) to feed into provisionPhoneNumber. Call this first when the org has no line to send from (listCommunicationChannels returned an empty twilioPhoneNumbers).

curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operationId": "searchAvailablePhoneNumbers",
    "variables": {}
  }'
import { GoliathClient } from '@goliath-data/sdk'

const goliath = new GoliathClient({
  apiKey: process.env.GOLIATH_API_KEY!,
  baseUrl: 'https://server.goliathdata.com',
})

const result = await goliath.phoneNumbers.searchAvailablePhoneNumbers({})
const res = await fetch('https://server.goliathdata.com/api/v1/call', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.GOLIATH_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    operationId: 'searchAvailablePhoneNumbers',
    variables: {}
  }),
})
const { data, errors } = await res.json()

Variables

The example sends only what the schema requires. Some operations also need one of several optional variables (one filter or another, say); the description above says which.

areaCodeInt

Response

What comes back under data: a list shows as one entry, and a value as its type.

response shape
{
  "data": {
    "twilioQuery": {
      "searchAvailablePhoneNumbers": [
        {
          "phoneNumber": "…",
          "friendlyName": "…",
          "locality": "…",
          "region": "…",
          "postalCode": "…"
        }
      ]
    }
  }
}

Errors

Behaviour

A read. It rejects an Idempotency-Key header with 400 bad_request.