Authentication
Textly is an http API, in order to use it you're going to need to obtain an API key and then use it as a bearer token when interacting with textly
Getting an API key
- Head to textly's dashboard page
- Login to your account
- After successful login you should be taken to the dashboard homepage
- Click on developer options
- Click on "generate new key", enter the key's name and wait until a key is generated for you
- Copy the key!
Using your API key
After getting an API key from the dashboard you can preform GET /api/v1/client/me
with the API key as a bearer token
in the authorization header:
- TypeScript
- PHP (Laravel)
- Curl
const response = await fetch("https://api.textly.ly/api/v1/client/me", {
method: "GET",
headers: new Headers({
Authorization: "Bearer <YOUR API KEY>",
}),
});
console.log(await response.json()); // { client: { ... } }
use Illuminate\Support\Facades\Http;
$response = Http::withHeaders([ 'Authorization' => 'Bearer $token' ])
->get('https://api.textly.ly/api/v1/client/me', []);
info($response->json()); // { client: { ... } }
curl -X GET https://api.textly.ly/api/v1/client/me \
-H "Authorization: Bearer <YOUR API KEY>"
This route allows us to check if our API key is working and to also fetch details about your account
Handling errors
You might get an error if:
- Your API key was disabled by an admin or a you've disabled it via the dashboard
- Your account was disabled an an admin
Anyways getting an error means receiving a response with a status of 400 and a json body that has an errors array
{
"errors": [
{
"message": "Unauthorized",
"error_code": "UNAUTHORIZED"
}
]
}
Things to take into account
Keeping your auth token safe and secure is your responsibility make sure to store it securely (possibly with encryption), be sure to use the dashboard to delete old tokens no longer in use