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_api_1234567890abcdefghijklmnop" \
  -H "Content-Type: application/json" \
  -d '{"query":"mutation { deleteIssue(id: \"issue123\") { 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 { deleteIssue(id: \"issue123\") { 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 { deleteIssue(id: \"issue123\") { 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 = new URL('https://api.linear.app/graphql');
const headers = {
  'Authorization': `Bearer ${process.env.LINEAR_API_TOKEN}`,
  'Content-Type': 'application/json'
};
const body = JSON.stringify({
  query: 'mutation { deleteIssue(id: "issue123") { success } }'
});

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

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 { deleteIssue(id: "issue123") { success } }'
};

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

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"
	req, err := http.NewRequest("DELETE", url, nil)
	if err != nil {
		log.Fatal(err)
	}

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

	body := GraphQLRequest{
		Query: "mutation { deleteIssue(id: \"issue123\") { success } }",
	}
	bodyBytes, _ := json.Marshal(body)
	req.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))

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

	if resp.StatusCode >= 400 {
		log.Fatalf("HTTP error! status: %s", resp.Status)
	}

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

PHP · cURL

<?php

$url = 'https://api.linear.app/graphql';
$headers = [
    'Authorization: Bearer ' . getenv('LINEAR_API_TOKEN'),
    'Content-Type: application/json',
];
$data = ['query' => 'mutation { deleteIssue(id: "issue123") { success } }'];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    die('Error: ' . curl_error($ch));
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode >= 400) {
    die("HTTP error! status: $httpCode");
}

print_r(json_decode($response, true));

Ruby · net/http

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

url = URI.parse('https://api.linear.app/graphql')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url.path)
request['Authorization'] = "Bearer #{ENV['LINEAR_API_TOKEN']}"
request['Content-Type'] = 'application/json'
request.body = { query: 'mutation { deleteIssue(id: "issue123") { success } }' }.to_json

response = http.request(request)
if response.code.to_i >= 400
  raise "HTTP error! status: #{response.code}"
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 { deleteIssue(id: \"issue123\") { 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, httpResponse.statusCode < 400 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 reqwest::blocking::Client;
use std::env;

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

    let body = serde_json::json!({
        "query": "mutation { deleteIssue(id: \"issue123\") { success } }"
    });

    let response = client
        .delete(url)
        .header("Authorization", format!("Bearer {}", token))
        .header("Content-Type", "application/json")
        .json(&body)
        .send()?;

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

    let json: serde_json::Value = response.json()?;
    println!("{}", json);
    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 client = new HttpClient();
        var url = "https://api.linear.app/graphql";
        var token = Environment.GetEnvironmentVariable("LINEAR_API_TOKEN");

        var request = new HttpRequestMessage(HttpMethod.Delete, url);
        request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
        request.Content = new StringContent(
            JsonSerializer.Serialize(new { query = "mutation { deleteIssue(id: \"issue123\") { success } }" }),
            System.Text.Encoding.UTF8,
            "application/json"
        );

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

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

Translation notes

  • Bearer token is read from environment variable LINEAR_API_TOKEN
  • JSON body is sent as a structured object, not a raw string
  • Error handling checks HTTP status code and raises an exception if >= 400
  • All implementations use idiomatic HTTP clients for their language
  • Python examples use both requests and httpx for completeness

Common pitfalls when porting

  • Forgetting to set the Authorization header will cause authentication failures
  • Sending the JSON body as a raw string instead of a structured object may lead to encoding issues
  • Not checking the HTTP status code can result in silent failures
  • In Go, forgetting to close the response body can lead to resource leaks
  • In Swift, the task must be started with task.resume() to execute
  • In Rust, blocking client is used for simplicity; async version would require a runtime

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. This prevents accidental exposure of tokens in version control or logs.

Can I use a different HTTP method for this request?

No, the Linear GraphQL API requires a DELETE method for this mutation. Using a different method will result in an error.

What happens if the LINEAR_API_TOKEN environment variable is not set?

The application will fail to authenticate and likely throw an error when trying to access the environment variable. Ensure the variable is set before running the code.

Is it safe to log the response body?

In production, you may want to log only the status code and headers for debugging, not the full response body, to avoid leaking sensitive data.