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_abc123def456ghi789jkl012mno345" \
  -H "Content-Type: application/json" \
  -d '{"query":"mutation { issueDelete(input: { id: \"issue123\" }) { success } }"}'

Python · requests

import os
import requests

url = "https://api.linear.app/graphql"
headers = {
    "Authorization": f"Bearer {os.environ['LINEAR_API_KEY']}",
    "Content-Type": "application/json"
}
data = {
    "query": "mutation { issueDelete(input: { 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_KEY']}",
    "Content-Type": "application/json"
}
data = {
    "query": "mutation { issueDelete(input: { 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';

const url = 'https://api.linear.app/graphql';
const headers = {
  'Authorization': `Bearer ${process.env.LINEAR_API_KEY}`,
  'Content-Type': 'application/json'
};
const data = {
  query: 'mutation { issueDelete(input: { id: "issue123" }) { 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';

const url = 'https://api.linear.app/graphql';
const headers = {
  'Authorization': `Bearer ${process.env.LINEAR_API_KEY}`,
  'Content-Type': 'application/json'
};
const data = {
  query: 'mutation { issueDelete(input: { id: "issue123" }) { 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 requestBody struct {
	Query string `json:"query"`
}

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

	body := requestBody{
		Query: "mutation { issueDelete(input: { id: \"issue123\" }) { success } }",
	}
	jsonBody, err := json.Marshal(body)
	if err != nil {
		log.Fatal(err)
	}

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

	req.Header.Set("Authorization", "Bearer "+apiKey)
	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, body)
	}

	var result map[string]interface{}
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		log.Fatal(err)
	}
	fmt.Println(result)
}

PHP · cURL

<?php

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

$data = [
    'query' => 'mutation { issueDelete(input: { id: "issue123" }) { success } }'
];

$options = [
    'http' => [
        'method' => 'DELETE',
        'header' => [
            'Authorization: Bearer ' . $apiKey,
            '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')
api_key = ENV.fetch('LINEAR_API_KEY')

body = {
  query: 'mutation { issueDelete(input: { id: "issue123" }) { success } }'
}

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

request = Net::HTTP::Delete.new(url.path, {
  'Authorization' => "Bearer #{api_key}",
  'Content-Type' => 'application/json'
})
request.body = body.to_json

response = http.request(request)

unless response.is_a?(Net::HTTPSuccess)
  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_KEY"] ?? "")", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body: [String: Any] = [
    "query": "mutation { issueDelete(input: { 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, (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 reqwest::blocking::Client;
use std::env;

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

    let client = Client::new();
    let body = serde_json::json!({
        "query": "mutation { issueDelete(input: { id: \"issue123\" }) { success } }"
    });

    let response = client
        .delete(url)
        .header("Authorization", format!("Bearer {}", api_key))
        .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.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var url = "https://api.linear.app/graphql";
        var apiKey = Environment.GetEnvironmentVariable("LINEAR_API_KEY");
        if (string.IsNullOrEmpty(apiKey))
        {
            Console.WriteLine("LINEAR_API_KEY environment variable not set");
            return;
        }

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

        var response = await client.SendAsync(request);
        if (!response.IsSuccessStatusCode)
        {
            Console.WriteLine($"HTTP error! status: {response.StatusCode}");
            return;
        }

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

Translation notes

  • All implementations use idiomatic HTTP clients for each language.
  • Bearer token is read from environment variable LINEAR_API_KEY to avoid hardcoding.
  • JSON body is constructed as a dictionary/object literal, not a raw string.
  • Error handling checks HTTP status and reads response body where applicable.
  • DELETE method is preserved in all implementations.
  • Content-Type header is set to application/json in all implementations.

Common pitfalls when porting

  • Forgetting to set LINEAR_API_KEY environment variable will cause failures.
  • In Go, ensure the http.Client is properly closed (using defer resp.Body.Close()).
  • In Swift, URLSession tasks are asynchronous; use RunLoop.main.run() for synchronous execution in examples.
  • In Rust, the reqwest blocking client is used for simplicity; async version would require additional setup.
  • In PHP, ensure allow_url_fopen is enabled if using file_get_contents.
  • In Ruby, Net::HTTP may require additional SSL configuration in some environments.

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 use DELETE for a GraphQL mutation?

GraphQL mutations are typically sent via POST, but the Linear API accepts mutations via DELETE with a JSON body. This is API-specific behavior.

Can I use a different HTTP client library?

Yes, but ensure it supports the DELETE method, custom headers, and JSON bodies. Idiomatic libraries are preferred for maintainability.

How do I handle pagination or large responses?

Most libraries provide streaming or chunked response handling. For large responses, consider streaming the body instead of reading it all at once.