Basic HTTP authentication

HTTP Basic authentication works on all Sinch REST APIs. Basic auth is often the preferred option for testing because it is simple and easy to use.

Basic authentication is sent in the authorization header with each call.

No matter the programming language, there are three main components for successful basic authentication in a request:

  • The designation of authorization type, which is basic
  • The username , which in Sinch's case is YOUR_Key_ID , corresponding to your project
  • The password , which is YOUR_Key_Secret , again, corresponding to the project

You can view and manage your API credentials here (or here if you're using the beta version of the Customer Dashboard).

Need help?

Check out this article for a walk-through on finding your key and secret.

When you're ready for production, be sure to check out our OAuth2.0 authentication process for greater security.

Use basic authentication credentials in an API call

  1. First, create a new project in the Customer Dashboard by clicking New Key .

    If you are using the beta version of the Customer Dashboard, create a new project here instead.

  2. Copy your project ID , key ID , and key secret .
    Important:

    Keep your key secret somewhere safe as it is only viewable upon initial project creation. The project ID and key ID are always readily available in the Customer Dashboard. If you misplace your key secret, simply generate a new key!

  3. Use your Key ID as the username (sometimes called the client_id ) and your key secret as the password (can be referred to as the client_secret ) in every call made to a Sinch API.

Examples

This example will get available numbers in the US using the Numbers API. Replace all relevant parameters with your credential (including the curly braces {}).

Copy
Copied
curl -i -X GET \
'https://numbers.api.sinch.com/v1/projects/{YOUR_projectId}/availableNumbers?regionCode=US&type=LOCAL' \
  -H 'Content-Type: application/json' \
  -u {YOUR_Key_ID}:{YOUR_Key_Secret}

That's it!

Next step

Search for a number

Was this page helpful?