Skip to content

Using the AuthRamp GraphQL API

Use AuthRamp's GraphQL API to manage your applications remotely. Nearly all operations performed via the Dashboard are supported in the GraphQL API.

What is GraphQL?

GraphQL is an API and data query language for APIs. As an alternative to REST-based APIs, GraphQL is more flexible, strongly typed, clearly defined, and allows complex hiearchial queries with fewer calls.

For more information about GraphQL, see GraphQL.org

Authenticating your code with AuthRamp's API

Screenshot of Creating an API Key

To use the AuthRamp API, you must first obtain an API Key from the AuthRamp dashboard on the API Keys section of Settings. Once created, copy down the key for future use. API Keys are issued per AuthRamp Application. Copy the secret text of the API Key and send it to all API requests in the HTTP API-Key header.

Making your first query

Once you have your API Key, try using it to get a list of applications. Here are a few examples in different languages. We simply pass our API key and make a simple query.

{applications {total edges {node {id name}}}}
POST /graphql-api HTTP/1.1
Api-Key: --YOUR API KEY--
Content-Type: application/json
Host: authramp.com
Content-Length: 59

{"query":"{applications {total edges {node {id name}}}}\n"}
curl --request POST \
  --url https://authramp.com/graphql-api \
  --header 'api-key: --YOUR API KEY--' \
  --header 'content-type: application/json' \
  --data '{"query":"{applications {total edges {node {id name}}}}\n"}'
var client = new RestClient("https://authramp.com/graphql-api");
var request = new RestRequest(Method.POST);
request.AddHeader("api-key", "--YOUR API KEY--");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"query\":\"{applications {total edges {node {id name}}}}\\n\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
package main

import (
    "fmt"
    "strings"
    "net/http"
    "io/ioutil"
)

func main() {

    url := "https://authramp.com/graphql-api"

    payload := strings.NewReader("{\"query\":\"{applications {total edges {node {id name}}}}\\n\"}")

    req, _ := http.NewRequest("POST", url, payload)

    req.Header.Add("api-key", "--YOUR API KEY--")
    req.Header.Add("content-type", "application/json")

    res, _ := http.DefaultClient.Do(req)

    defer res.Body.Close()
    body, _ := ioutil.ReadAll(res.Body)

    fmt.Println(res)
    fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://authramp.com/graphql-api")
  .header("api-key", "--YOUR API KEY--")
  .header("content-type", "application/json")
  .body("{\"query\":\"{applications {total edges {node {id name}}}}\\n\"}")
  .asString();
import axios from "axios";

const options = {
  method: 'POST',
  url: 'https://authramp.com/graphql-api',
  headers: {
    'api-key': '--YOUR API KEY--',
    'content-type': 'application/json'
  },
  data: '{"query":"{applications {total edges {node {id name}}}}\n"}'
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://authramp.com/graphql-api",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"query\":\"{applications {total edges {node {id name}}}}\\n\"}",
  CURLOPT_HTTPHEADER => [
    "api-key: --YOUR API KEY--",
    "content-type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https://authramp.com/graphql-api"

payload = "{\"query\":\"{applications {total edges {node {id name}}}}\\n\"}"
headers = {
    'api-key': "--YOUR API KEY--",
    'content-type': "application/json"
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)

Using the API Explorer

AuthRamp includes a GraphQL API Explorer you can use to experiment with the API in real time. Note that when using the web-based explorer, you will be using your user account's credentials, not the API key; this is only for testing. In your code base, use your API key.

Looking for a good GraphQL GUI Client?

We recommend Insomia, which you can use to test GraphQL and other HTTP APIs on the desktop.