API Introduction
Base URL
The base URL for Plunk's API is https://api.useplunk.com/v1
.
Authorization
Every request to Plunk's API needs to be authenticated with the public or secret key associated with your project. You can find these keys in the API settings of your project.
👋🏼
Only use your secret key in a secure, backend environment. Never expose your secret key to the public. In case you do, regenerate your secret key immediately.
Once you have your key, you can authenticate your requests by passing it as a Bearer token in the Authorization header.
await fetch('https://api.useplunk.com/v1', {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer API_KEY", // Put your API key here
},
body: JSON.stringify({
"event": "new-project",
"email": "hello@useplunk.com",
}),
});
import requests
requests.post(
"https://api.useplunk.com/v1/track",
headers={
"Content-Type": "application/json",
"Authorization": "Bearer API_KEY" # Put your API key here
},
json={
"event": "new-project",
"email": "hello@useplunk.com",
},
)
curl --location --request POST 'https://api.useplunk.com/v1' \
--header 'Authorization: Bearer API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"email": "hello@useplunk.com", "event": "new-project"}'
<?php
$client = new Client();
$request = new Request('POST', 'https://api.useplunk.com/v1', ['Authorization' => 'Bearer API_KEY', 'Content-Type' => 'application/json'], '{
"event": "new-project",
"email": "hello@useplunk.com",
}');
$res = $client->sendAsync($request)->wait();
require "uri"
require "json"
require "net/http"
url = URI("https://api.useplunk.com/v1/track")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer API_KEY" # Put your API key here
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"event": "new-project",
"email": "hello@useplunk.com",
})
response = https.request(request)
Response Codes
Plunk's API uses conventional HTTP response codes to indicate the success or failure of an API request.
Status Code | Description |
---|---|
200 | The request was successful. |
400 | The request was invalid. Your request body is likely missing a required field. |
401 | The request was unauthorized. Your API key is invalid or not properly formatted. |
402 | You have hit your plan's monthly limit. Upgrade, wait until next month, or contact us if your project is on an enterprise plan. |
Last updated on May 2, 2023