# Quickstart

> Create an API key, find a service and open your first request with the Duty API in five minutes.

You will create a key, look up the service to file against, open a request and read it back.

<Steps>

1. **Create an API key.** In the Duty portal go to **Integrations → Keys and webhooks** and select **Create key**. Turn on **Write access** so the key can open requests. Copy the key: it starts with `gm_sd_` and is shown only once.

   Keep it in an environment variable rather than in your code:

   ```sh
   export DUTY_API_KEY="gm_sd_…"
   ```

   <Aside type="tip">Want to try it here first? Select **API key** at the top of this page, paste the key, and every reference page gets a working **Try it** panel.</Aside>

2. **Find the service.** Every request belongs to a service of your catalog. List them and note the `id` of the one to use:

   ```sh
   curl https://api.client.service-desk.goldmaster.io/v1/services \
     -H "Authorization: Bearer $DUTY_API_KEY"
   ```

   ```json
   {
     "data": [
       { "id": 12, "name": "VPN and remote access", "description": "Connection problems and access requests", "defaultPriority": "medium", "requiresApproval": false }
     ]
   }
   ```

3. **Open the request.** Send the service, a subject, a description and who the request is for:

   <Tabs syncKey="code">
   <TabItem label="cURL">

   ```sh
   curl https://api.client.service-desk.goldmaster.io/v1/tickets \
     -H "Authorization: Bearer $DUTY_API_KEY" \
     -H "Content-Type: application/json" \
     -d '{
       "serviceId": 12,
       "subject": "VPN disconnects every few minutes",
       "description": "Since this morning the VPN drops every 5 to 10 minutes.",
       "contact": { "name": "Ana Pérez", "email": "ana.perez@example.com" }
     }'
   ```

   </TabItem>
   <TabItem label="JavaScript">

   ```js
   const response = await fetch('https://api.client.service-desk.goldmaster.io/v1/tickets', {
     method: 'POST',
     headers: {
       Authorization: `Bearer ${process.env.DUTY_API_KEY}`,
       'Content-Type': 'application/json',
     },
     body: JSON.stringify({
       serviceId: 12,
       subject: 'VPN disconnects every few minutes',
       description: 'Since this morning the VPN drops every 5 to 10 minutes.',
       contact: { name: 'Ana Pérez', email: 'ana.perez@example.com' },
     }),
   });
   const { data: request } = await response.json();
   console.log(request.number); // GM-000123
   ```

   </TabItem>
   <TabItem label="Python">

   ```python
   import os
   import requests

   response = requests.post(
       "https://api.client.service-desk.goldmaster.io/v1/tickets",
       headers={"Authorization": f"Bearer {os.environ['DUTY_API_KEY']}"},
       json={
           "serviceId": 12,
           "subject": "VPN disconnects every few minutes",
           "description": "Since this morning the VPN drops every 5 to 10 minutes.",
           "contact": {"name": "Ana Pérez", "email": "ana.perez@example.com"},
       },
       timeout=30,
   )
   response.raise_for_status()
   print(response.json()["data"]["number"])  # GM-000123
   ```

   </TabItem>
   </Tabs>

   The API answers `201 Created` with the full request. Its `number` (such as `GM-000123`) identifies it from now on, and `responseDueAt` and `resolutionDueAt` already carry the targets of your service level agreement.

4. **Read it back.** Get the request with its current status and the transitions it can make next:

   ```sh
   curl https://api.client.service-desk.goldmaster.io/v1/tickets/GM-000123 \
     -H "Authorization: Bearer $DUTY_API_KEY"
   ```

</Steps>

## What's next

- Keep your system in step with [webhooks](/en/api/webhooks/) instead of polling.
- Sync existing requests with [`updatedSince`](/en/api/guides/sync-requests/).
- Learn the [error format](/en/api/errors/) so your integration can explain what went wrong.
