Getting started

Welcome to the WriteText.ai API documentation. This API provides a suite of tools for text generation, image processing, content review, and more. The API is designed to be intuitive and flexible, allowing developers to integrate powerful text and image capabilities into their applications.

Base URL

The base URL for the API is: https://api.writetext.ai/

API Authentication Guide

WriteText.ai uses the OAuth 2.0 authentication standard, with modifications to accommodate API keys. This guide outlines how to obtain an API key, how to register a domain for your account, and how to acquire an access token for making requests to the WriteText.ai API.

1. API Key
When you sign up for the WriteText.ai API service, you will be issued an API Key. This API key is required for authenticating your requests to obtain access tokens, which are used for all API interactions. You will use the provided API key to request an access token specific to the domain registered under your account.

2. Obtaining an Access Token
Before making requests to the WriteText.ai API, you must first obtain an access token. The access token is tied to a specific domain registered under your account and expires after 24 hours. You will need to request a new token after it expires.

Step 1: Domain Registration
We automatically register a domain for your account when you sign up. You can also enter your domain manually when creating an API key.

Step 2: Requesting an Access Token
Once a domain is registered under your account, you can use the following method to obtain an access token.

API Request:
Method: GET
URL:
https://api.writetext.ai/web/apitoken/accesstoken

Headers:
WriteTextAI-Token: {API Key}

Step 3: Handling the Response

If your request is successful, you will receive a response with the following fields:

  • region: The region-specific base URL for the text generation server (e.g., api-eu.writetext.ai). This URL will be used for all subsequent API calls.
  • platform: The platform in use (this will be "API" for manually entered domains).
  • access_token: The access token required for authentication in API requests. The access token is valid for 24 hours.
  • expires_in: The number of seconds until the access token expires (typically 86,400 seconds or 24 hours).
  • token_type: The type of the token (this will always be "Bearer").
  • scope: The access scope granted (in this case, "Text")

3. Using the Access Token

After obtaining the access token, you can use it to authenticate your API requests to the WriteText.ai servers.

To authenticate, include the access token in the Authorization header of each API request as follows:
Authorization: Bearer {access_token}

For example:
GET https://api-eu.writetext.ai/text/generate
Headers:
Authorization: Bearer eyJhbGciO………aCGEItEH0Q

4. Token Expiry and Renewal

The access token is valid for 24 hours. After the token expires, you will need to make another request to the /apitoken/accesstoken endpoint to obtain a new token.

If your application requires continuous access, ensure you have logic in place to request a new token before the current one expires.

Summary of the Process
  1. Obtain your API key when you sign up for WriteText.ai services.

  2. Register your domain with WriteText.ai (automatically done at sign-up, or contact support for additional domains).

  3. Request an access token by using the /apitoken/accesstoken endpoint.

  4. Use the access token in the Authorization header for all API requests.

  5. Renew your access token every 24 hours, as it expires.

Available Endpoints

  • Credit Endpoints - You can check your credit balance or if you have enough credits for a particular operation.

  • Generate endpoints - These are where the main text generation functionalities are, like generating text for product description, updating the text and marking it as published.

  • Image Endpoints - You can upload images here for use in image analysis and image alt text generation.

  • Keyword Endpoints - These include the AI powered keyword research endpoint that can aid you in creating a workflow for regularly updating your generated text with higher volume keywords.

  • Review Endpoints - Primarily used by the Chrome extension to mark text at various product pages for review.

  • Suggestion Endpoints - AI generated suggestions. For now, only audience suggestions are available.

Common Issues

  1. Invalid API Key: Ensure that you are passing the correct API key in the WriteTextAI-Token header. If the key is incorrect or expired, you will receive a 401 Unauthorized error.

  2. Token Expired: If your access token has expired, make a new request to the /apitoken/accesstoken endpoint to get a new one.

Rate limiting

The API enforces rate limits to ensure fair usage. Exceeding the rate limit will result in a 429 Too Many Requests response.
For any additional questions or assistance, please contact WriteText.ai support at hello@writetext.ai