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_1234567890abcdef" -H "Content-Type: application/json" -d '{"query":"mutation {deleteIssue(id: \"issue-id\") {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 {deleteIssue(id: \"issue-id\") {success}}"}

response = requests.delete(url, headers=headers, json=data)
if response.status_code >= 400:
    print(response.text)

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 {deleteIssue(id: \"issue-id\") {success}}"}

with httpx.Client() as client:
    response = client.delete(url, headers=headers, json=data)
    if response.status_code >= 400:
        print(response.text)

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_KEY}`,
  'Content-Type': 'application/json'
};
const data = { query: 'mutation {deleteIssue(id: "issue-id") {success}}' };

fetch(url, {
  method: 'DELETE',
  headers,
  body: JSON.stringify(data)
})
  .then(res => {
    if (res.status >= 400) {
      return res.text();
    }
  })
  .then(console.log);

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_KEY}`,
  'Content-Type': 'application/json'
};
const data = { query: 'mutation {deleteIssue(id: "issue-id") {success}}' };

axios.delete(url, { headers, data })
  .then(res => {
    if (res.status >= 400) {
      console.log(res.data);
    }
  })
  .catch(console.error);

Go · net/http

package main

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

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")
	}

	req, err := http.NewRequest("DELETE", url, nil)
	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)
		fmt.Println(string(body))
	}
}

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');
}

$headers = [
    'Authorization: Bearer ' . $apiKey,
    'Content-Type: application/json'
];

$data = ['query' => 'mutation {deleteIssue(id: "issue-id") {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_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) {
    echo $response;
}
curl_close($ch);

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')

headers = {
  'Authorization' => "Bearer #{api_key}",
  'Content-Type' => 'application/json'
}

data = { query: 'mutation {deleteIssue(id: "issue-id") {success}}' }

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

request = Net::HTTP::Delete.new(url.request_uri, headers)
request.body = data.to_json

response = http.request(request)
if response.code.to_i >= 400
  puts response.body
end

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 {deleteIssue(id: \"issue-id\") {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)
        return
    }
    guard let httpResponse = response as? HTTPURLResponse,
          httpResponse.statusCode >= 400 else { return }
    if let data = data, let body = String(data: data, encoding: .utf8) {
        print(body)
    }
}
task.resume()

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 response = client
        .delete(url)
        .header("Authorization", format!("Bearer {}", api_key))
        .header("Content-Type", "application/json")
        .json(&serde_json::json!({"query": "mutation {deleteIssue(id: \"issue-id\") {success}}"}))
        .send()?;

    if response.status().as_u16() >= 400 {
        println!("{}", response.text()?);
    }

    Ok(())
}

C# · HttpClient

using System;
using System.Net.Http;
using System.Net.Http.Headers;
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;
        }

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

        var body = new { query = "mutation {deleteIssue(id: \"issue-id\") {success}}" };
        var response = await client.DeleteAsync(url, new StringContent(System.Text.Json.JsonSerializer.Serialize(body)));

        if (!response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
    }
}

Translation notes

  • Bearer token is read from LINEAR_API_KEY environment variable
  • JSON body is sent as a structured object, not a raw string
  • Error handling checks HTTP status code >= 400
  • All implementations use idiomatic HTTP clients for their language
  • Go and Rust use blocking clients for simplicity; async variants are available

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 before reading the response body can cause 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 the request

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 also allows the same code to be used across different environments (dev, staging, prod) without modification.

Can I use async/await in Go or Rust for this request?

Yes. In Go, you can use the `net/http` package with goroutines or the `golang.org/x/net/context` package for cancellation. In Rust, you can use `reqwest` with async/await by enabling the `async-std` or `tokio` feature.

Why is the JSON body sent as a structured object in some languages but as a raw string in others?

Idiomatic HTTP clients in Python (requests/httpx), Node.js (axios/fetch), Ruby, and C# automatically serialize objects to JSON. In Go and Rust, we explicitly serialize the object to a JSON string to ensure proper content-type handling.