Learn how to authenticate with the TextUnited API.

The TextUnited API supports two types of authentication to ensure secure access to its functionalities: Basic Auth and JSON Web Tokens (JWT) authentication. Each method has its advantages, and you can choose the one that best fits your integration needs. This section outlines how to obtain your API credentials (API Key and Company ID) for Basic Auth and introduces the concept of JWT tokens for those interested in using JWT authentication.


ℹ️

Note

You have the freedom to choose either Basic Auth or JWT authentication based on your preference or project requirements. Both methods are supported by TextUnited, allowing you to securely access the API's functionalities. If you prefer JWT authentication, you can skip directly to the JWT Authentication section for detailed instructions on obtaining and managing JSON Web Tokens.


Obtaining Your API Key and Company ID

Step 1: Sign Up or Log In

Visit TextUnited website at TextUnited to sign up for a new account or log in if you already have one.

Sign Up and Login Page

Sign Up and Login Page on TextUnited

Step 2: Navigate to the API Section

Once Logged in, locate the API section in your dashboard. This is where you can manage your API keys and view your API usage statistics.

Navigating to the API Section

Navigating to the API Section on TextUnited

Step 3: Generate a New API Key

Look for an option to generate a new API key. Clicking this button will create a new key for you. Ensure you save this key securely, as you won't be able to see it again after leaving the page.

Generating an API Key on TextUnited

Generating an API Key on TextUnited


Using Your API Key and Company ID

To authenticate your requests to the TextUnited API using Basic Auth, you need to encode your API key and company ID in Base64. This encoded string is then included in the Authorization header with the prefix Basic. Here's an example using Python and the requests library:

import requests
from requests.auth import HTTPBasicAuth

url = "https://api.textunited.com/v1/SegmentProjects"
username = "<YOUR_COMPANY_ID>"
password = "<YOUR_API_KEY>"

# Basic Authentication headers
headers = {
    "Content-Type": "application/json"
}

# Perform the GET request with Basic Authentication
response = requests.get(url, headers=headers, auth=HTTPBasicAuth(username, password))

# Check the response
print(response.status_code)
print(response.json())  # or response.text, depending on the expected response format

Replace "<YOUR_API_KEY>" with your actual API key and "<YOUR_COMPANY_ID>" with your actual company ID. This ensures that your requests are authenticated and authorized to access the API's resources.


Introduction to JSON Web Token Authentication

JWT authentication offers a more flexible and secure method for accessing the TextUnited API. A JSON Web Token is a compact, URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JSON object that is digitally signed using JSON Web Signature (JWS).

Creating a JSON Web Token

To initiate JWT authentication, you must first obtain a JSON Web Token. This is done by sending a POST request to the /authentication/token endpoint. You need to include your credentials—specifically, the username (your email address) and password you used when creating your TextUnited account—in the request body.

Refreshing a JSON Web Token

As JSON Web Tokens have an expiration time, they need to be refreshed periodically. To refresh your JSON Web Token, you simply send another POST request to the /authentication/RefreshToken endpoint. This time, you will pass along your existing JSON Web Token in the request body. Upon successful validation, you will receive a new access token and a new refresh token, allowing you to continue accessing the API securely.

For detailed instructions on creating and refreshing JSON Web Token, please refer to our dedicated documentation on JSON Web Token Authentication.

By choosing either Basic Auth or JWT authentication, you can securely access the TextUnited API's extensive features, facilitating seamless integration of translation and localization services into your applications.