Introduction
  • 21 Feb 2025
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Introduction

  • Dark
    Light

Article summary

Introduction

This is the REST API for LimaCharlie.io. See https://docs.limacharlie.io/docs/api-keys for additional authentication information.

Getting a JWT

Simply issue an HTTP POST such as:

curl -X POST "https://jwt.limacharlie.io" -H "Content-Type: application/x-www-form-urlencoded" -d "oid=<YOUR_OID>&secret=<YOUR_API_KEY>"

where the oid parameter is the organization id as found through the web interface and the secret parameter is the API key.

If you need a JWT that is specific to a single org, you can pass the oid parameter as specified. If you need a JWT that is not specific to a single org, you can pass - as the oid parameter.

The return value is a simple JSON response with a jwt component which is the JSON web token. This token is only valid for one hour to limit the possible damage of a leak, and make the deletion of the API keys easier.

Example Response:

{ "jwt": "<JWT_VALUE_HERE>" }

Additionally, if you need an API key which is scoped to a specific user, include uid=<YOUR_UID> instead of oid parameter and instead of organization API key, you need to use the user scoped API key.

You can generate a user scoped API key at https://app.limacharlie.io/profile -> User API Keys and obtain your User ID by clicking "User ID" icon on the right top side of the same page.

Example cURL request to obtain JWT token which is scoped to a specific user:

curl -X POST "https://jwt.limacharlie.io" -H "Content-Type: application/x-www-form-urlencoded" -d "uid=<YOUR_UID>&secret=<YOUR_USER_SCOPED_API_KEY>"

Keep in mind that using organization scoped tokens is preferred. You should only user a user scoped token if there is a specific need for it or you are using an API endpoint which operates on the user behalf and requires user scoped token (e.g. POST /v1/users/invite).

Python Example

import requests
import json

# Step 1 - Generate a JWT
def generate_jwt():
    api_key = $LIMACHARLIE_API_KEY
    uid = $LIMACHARLIE_UID

    url = "https://jwt.limacharlie.io?uid=%s&secret=%s&oid=-" % (uid, api_key)

    try:
        r = requests.get(url)
        jwt = r.json()["jwt"]
        return jwt

    except:
        return None


# Step 2 - Make an API request
def create_org(loc, name):
    url = "https://api.limacharlie.io/v1/orgs/new"

    headers = {
        "Content-Type": "application/json",
        "Authorization": "Bearer %s" % (generate_jwt()),
    }
    params = {"loc": loc, "name": name}
    response = requests.request("POST", url, headers=headers, params=params)

    return json.loads(response.text)

Terms of Service


Was this article helpful?

What's Next