Qaynaq LABS · TOOLS

CURL → CODE · DELETE · BEARER

cURL → 10 languages

DELETE api.linear.app · body: json · secrets replaced with env vars.

Source cURL
curl -X DELETE https://api.linear.app/graphql \
  -H "Authorization: Bearer lin_1234567890" \
  -H "Content-Type: application/json" \
  -d '{"query":"mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }"'

Python · requests

import os
import requests

url = "https://api.linear.app/graphql"
headers = {
    "Authorization": f"Bearer {os.environ['LINEAR_API_TOKEN']}",
    "Content-Type": "application/json"
}
data = {
    "query": "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }"
}

response = requests.delete(url, headers=headers, json=data)
response.raise_for_status()
print(response.json())

Python · httpx

import os
import httpx

url = "https://api.linear.app/graphql"
headers = {
    "Authorization": f"Bearer {os.environ['LINEAR_API_TOKEN']}",
    "Content-Type": "application/json"
}
data = {
    "query": "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }"
}

with httpx.Client() as client:
    response = client.delete(url, headers=headers, json=data)
    response.raise_for_status()
    print(response.json())

Node.js · fetch

import fetch from 'node-fetch';
import { config } from 'dotenv';

config();

const url = 'https://api.linear.app/graphql';
const headers = {
  'Authorization': `Bearer ${process.env.LINEAR_API_TOKEN}`,
  'Content-Type': 'application/json'
};
const data = {
  query: 'mutation { issueDelete(id: "12345678-1234-1234-1234-123456789012") { success } }'
};

fetch(url, {
  method: 'DELETE',
  headers,
  body: JSON.stringify(data)
})
  .then(res => {
    if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
    return res.json();
  })
  .then(console.log)
  .catch(console.error);

Node.js · axios

import axios from 'axios';
import { config } from 'dotenv';

config();

const url = 'https://api.linear.app/graphql';
const headers = {
  'Authorization': `Bearer ${process.env.LINEAR_API_TOKEN}`,
  'Content-Type': 'application/json'
};
const data = {
  query: 'mutation { issueDelete(id: "12345678-1234-1234-1234-123456789012") { success } }'
};

axios.delete(url, { headers, data })
  .then(res => {
    if (res.status >= 400) throw new Error(`HTTP error! status: ${res.status}`);
    console.log(res.data);
  })
  .catch(console.error);

Go · net/http

package main

import (
	"encoding/json"
	"fmt"
	"io"
	"log"
	"net/http"
	"os"
)

type GraphQLRequest struct {
	Query string `json:"query"`
}

func main() {
	url := "https://api.linear.app/graphql"
	token := os.Getenv("LINEAR_API_TOKEN")
	if token == "" {
		log.Fatal("LINEAR_API_TOKEN environment variable not set")
	}

	reqBody := GraphQLRequest{
		Query: "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }",
	}
	body, _ := json.Marshal(reqBody)

	req, err := http.NewRequest("DELETE", url, bytes.NewBuffer(body))
	if err != nil {
		log.Fatal(err)
	}

	req.Header.Set("Authorization", "Bearer "+token)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	if resp.StatusCode >= 400 {
		body, _ := io.ReadAll(resp.Body)
		log.Fatalf("HTTP error! status: %d, body: %s", resp.StatusCode, string(body))
	}

	var result map[string]interface{}
	json.NewDecoder(resp.Body).Decode(&result)
	fmt.Println(result)
}

PHP · cURL

<?php

$url = 'https://api.linear.app/graphql';
$token = getenv('LINEAR_API_TOKEN');
if (empty($token)) {
    die('LINEAR_API_TOKEN environment variable not set');
}

$data = [
    'query' => 'mutation { issueDelete(id: "12345678-1234-1234-1234-123456789012") { success } }'
];

$options = [
    'http' => [
        'method' => 'DELETE',
        'header' => [
            'Authorization: Bearer ' . $token,
            'Content-Type: application/json'
        ],
        'content' => json_encode($data)
    ]
];

$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

if ($result === false) {
    die('Request failed');
}

$response = json_decode($result, true);
print_r($response);

Ruby · net/http

require 'net/http'
require 'json'
require 'uri'

url = URI.parse('https://api.linear.app/graphql')
token = ENV.fetch('LINEAR_API_TOKEN') { raise 'LINEAR_API_TOKEN environment variable not set' }

request = Net::HTTP::Delete.new(url)
request['Authorization'] = "Bearer #{token}"
request['Content-Type'] = 'application/json'
request.body = {
  query: 'mutation { issueDelete(id: "12345678-1234-1234-1234-123456789012") { success } }'
}.to_json

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

response = http.request(request)
unless response.is_a?(Net::HTTPSuccess)
  raise "HTTP error! status: #{response.code}, body: #{response.body}"
end

puts JSON.parse(response.body)

Swift · URLSession

import Foundation

let url = URL(string: "https://api.linear.app/graphql")!
var request = URLRequest(url: url)
request.httpMethod = "DELETE"
request.setValue("Bearer \(ProcessInfo.processInfo.environment["LINEAR_API_TOKEN"] ?? "")", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body: [String: Any] = [
    "query": "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }"
]
request.httpBody = try JSONSerialization.data(withJSONObject: body)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
        print("Error: \(error)")
        return
    }
    guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else {
        print("HTTP error! status: \((response as? HTTPURLResponse)?.statusCode ?? 0)")
        return
    }
    if let data = data, let json = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
        print(json)
    }
}
task.resume()
RunLoop.main.run()

Rust · reqwest

use std::env;
use reqwest::blocking::Client;
use serde_json::json;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let url = "https://api.linear.app/graphql";
    let token = env::var("LINEAR_API_TOKEN")?;

    let client = Client::new();
    let response = client
        .delete(url)
        .header("Authorization", format!("Bearer {}", token))
        .header("Content-Type", "application/json")
        .json(&json!({
            "query": "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }"
        }))
        .send()?;

    if !response.status().is_success() {
        return Err(format!("HTTP error! status: {}", response.status()).into());
    }

    let body = response.json::<serde_json::Value>()?;
    println!("{:?}", body);
    Ok(())
}

C# · HttpClient

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Text.Json;

class Program
{
    static async Task Main()
    {
        var url = "https://api.linear.app/graphql";
        var token = Environment.GetEnvironmentVariable("LINEAR_API_TOKEN");
        if (string.IsNullOrEmpty(token))
        {
            throw new Exception("LINEAR_API_TOKEN environment variable not set");
        }

        using var client = new HttpClient();
        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

        var body = new { query = "mutation { issueDelete(id: \"12345678-1234-1234-1234-123456789012\") { success } }" };
        var content = new StringContent(JsonSerializer.Serialize(body), System.Text.Encoding.UTF8, "application/json");

        var response = await client.DeleteAsync(url, content);
        if (!response.IsSuccessStatusCode)
        {
            throw new Exception($"HTTP error! status: {response.StatusCode}");
        }

        var responseBody = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseBody);
    }
}

Translation notes

  • All implementations use the idiomatic HTTP client for the language.
  • Bearer token is read from environment variable LINEAR_API_TOKEN.
  • JSON body is constructed as a dictionary/object literal.
  • Error handling checks HTTP status and reads response body where applicable.
  • DELETE method is preserved with correct headers and body.
  • Python implementations use both requests and httpx for completeness.

Common pitfalls when porting

  • Forgetting to set LINEAR_API_TOKEN environment variable before running.
  • Incorrectly serializing the JSON body (e.g., using raw strings instead of dicts).
  • Ignoring HTTP status codes in error handling.
  • Using HTTP instead of HTTPS for the API endpoint.
  • Not setting Content-Type header for JSON requests.
  • In Go, forgetting to close the response body or handle JSON decoding errors.

About cURL → code translation

cURL is the lingua franca of API documentation: every vendor docs page ships a cURL snippet you can paste into a terminal and immediately see the API working. Translating that into your actual application code shouldn't be a 20-minute Stack-Overflow safari, but without a good translator it usually is.

Qaynaq Labs' cURL → code tool reads the full command — method, URL, headers, query params, body type, and auth — and emits idiomatic client code in 10 languages. Authentication goes through environment variables by default, request bodies become language-native data structures (not raw JSON strings), and minimal error handling is included.

Frequently asked

Why is the bearer token read from an environment variable instead of being hardcoded?

Environment variables are used to avoid hardcoding secrets in source code, which is a security best practice. Secrets should never be committed to version control.

Can I use a different HTTP client library for these languages?

Yes, but the examples use the most idiomatic and widely-used libraries for each language to ensure clarity and maintainability.

Why is the DELETE method used with a request body?

While HTTP DELETE requests traditionally do not include a body, some APIs (like Linear's GraphQL endpoint) accept it. Always follow the API's documentation.