Option 2: Python (with requests and python-dotenv)
1. Install dependencies
pip install requests python-dotenv2. .env file
.env fileLINEAR_API_KEY=your_linear_api_key_here
LINEAR_TEAM_ID=your_linear_team_id_here3. create_issue.py
create_issue.pyimport os
import requests
from dotenv import load_dotenv
load_dotenv()
LINEAR_API_KEY = os.getenv("LINEAR_API_KEY")
TEAM_ID = os.getenv("LINEAR_TEAM_ID")
LINEAR_API_URL = "https://api.linear.app/graphql"
def create_issue(title, description):
query = """
mutation {
issueCreate(
input: {
teamId: "%s",
title: "%s",
description: "%s"
}
) {
success
issue {
id
identifier
url
}
}
}
""" % (TEAM_ID, title.replace('"', '\\"'), description.replace('"', '\\"'))
headers = {
"Authorization": f"Bearer {LINEAR_API_KEY}",
"Content-Type": "application/json"
}
response = requests.post(LINEAR_API_URL, json={"query": query}, headers=headers)
data = response.json()
if data.get("data") and data["data"]["issueCreate"]["success"]:
return data["data"]["issueCreate"]["issue"]["url"]
else:
raise Exception(f"Issue creation failed: {data}")
# Example usage
if __name__ == "__main__":
issue_url = create_issue("Bug report from user", "User uploaded file XYZ and app crashed.")
print("Created issue at:", issue_url)Last updated