> ## Client identification
>
> Requests to this API should include a `Client-Platform` header alongside
> `Authorization`, identifying the application, tool, or model making the
> request. This is used for integration support and analytics.
>
> Use your model or tool name, for example `claude-code` or `chatgpt`.
>
> Example:
>
> ```bash
> curl https://api.salaryboxapp.com/... \
>   -H "Authorization: Api-Key <api-key>" \
>   -H "Client-Platform: claude-code"
> ```

# Update Staff Schedule

PUT https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule
Content-Type: application/json

Sets a staff member's schedule, as the app's schedule editor does. `type` is `fixed` (default) or `flexible`. Shared rules: see [Writing data](/conventions#writing-data).

- **Fixed** (`type: fixed`, send `week`): a repeating weekly pattern. It **replaces** the whole current weekly pattern. `week` must have exactly 7 objects, each day once. `dates` is not allowed.
- **Flexible** (`type: flexible`, send `dates`): a roster of specific dates; needs the Roster plan feature. It **merges**: only the dates sent change, every other rostered date keeps what it has. Send 1 to 60 dates, each at most once, from 60 days back to 60 days ahead of the staff member's local today. A date up to today in a finalised payroll month is refused until payroll is unfrozen in the SalaryBox app. `week` is not allowed.
- Each day or date has either `shift_names` (1 to 10 exact shift names from `GET /attendance/shift`, no repeats) or `day_off: true`, never both and never neither.
- More than one shift on any day or date needs the Multiple Shift Assignment plan feature.
- Switching type either way is allowed and starts a new schedule version, as in the app. Fixed to flexible leaves only the dates sent scheduled (other dates are unscheduled). Flexible to fixed replaces the roster with the weekly pattern.
- A fixed request for a staff member whose schedule changes by week of the month (for example alternate Saturdays) is refused with `400` on `salarybox_id`; change it in the SalaryBox app.


Reference: https://docs.salarybox.in/api-reference/attendance/schedule-set

## Authentication

- `Authorization` header (required) (prefixed with ` Api-Key   `) — Format: "Api-Key \{api-key}"

## Request

### Body (application/json)

This endpoint expects an AttendanceScheduleSetRequest.

- `salarybox_id` (string, required) — The staff member.
- `type` (enum, optional, default: fixed) — `fixed` is a repeating weekly pattern (send `week`). `flexible` is a roster of specific dates (send `dates`; needs the Roster plan feature).
  - Allowed values: `fixed`, `flexible`
- `week` (list of AttendanceScheduleSetRequestWeekItems, optional) — Required when `type` is `fixed`; not allowed when `flexible`. Exactly 7 objects, one per day, each day once.
- `dates` (list of AttendanceScheduleSetRequestDatesItems, optional) — Required when `type` is `flexible`; not allowed when `fixed`. 1 to 60 dates, each at most once. Only these dates change; other rostered dates keep what they have. Dates may be up to 60 days ahead and 60 days back (local today of the staff member).

## Response

### 200

The schedule was saved. A fixed request returns `schedule_type: fixed` with the full `week`; a flexible request returns `schedule_type: flexible` with the `dates` sent, in request order.

- `message` (string, required)
- `status` (boolean, required)
- `data` (AttendanceScheduleSetResponseData, required)

## Errors

### 400 Bad Request Error

Validation failed, or the current schedule cannot be changed through the API.

- `message` (string, required)
- `status` (boolean, required)
- `errors` (map from string to any, optional, nullable)

### 403 Forbidden Error

The plan lacks Roster (flexible type) or Multiple Shift Assignment.

- `message` (string, required)
- `status` (boolean, required)
- `errors` (map from string to any, optional, nullable)

### 404 Not Found Error

No eligible active staff member with this `salarybox_id` exists in your company.

- `message` (string, required)
- `status` (boolean, required)
- `errors` (map from string to any, optional, nullable)

## Types

### AttendanceScheduleSetRequestWeekItems

- `day` (enum, required) — Day of the week.
  - Allowed values: `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `saturday`, `sunday`
- `shift_names` (list of string, optional) — Exact shift names from `GET /attendance/shift`. Send this or `day_off`, not both.
- `day_off` (boolean, optional) — `true` for a day off. Send this or `shift_names`, not both.

### AttendanceScheduleSetRequestDatesItems

- `date` (date, required) — Date as `YYYY-MM-DD`.
- `shift_names` (list of string, optional) — Exact shift names from `GET /attendance/shift`. Send this or `day_off`, not both, and not neither.
- `day_off` (boolean, optional) — `true` for a day off. Send this or `shift_names`, not both, and not neither.

### AttendanceScheduleSetResponseData

- `salarybox_id` (string, required)
- `schedule_type` (enum, required)
  - Allowed values: `fixed`, `flexible`
- `week` (list of AttendanceScheduleSetResponseDataWeekItems, optional) — Present when `schedule_type` is `fixed`. The full weekly pattern.
- `dates` (list of AttendanceScheduleSetResponseDataDatesItems, optional) — Present when `schedule_type` is `flexible`. The dates sent in this request, in request order.

### AttendanceScheduleSetResponseDataWeekItems

- `day` (string, required)
- `day_off` (boolean, required)
- `shift_names` (list of string, required)

### AttendanceScheduleSetResponseDataDatesItems

- `date` (date, required)
- `day_off` (boolean, required)
- `shift_names` (list of string, required)

## Examples

### Example

**Request**

```json
{
  "salarybox_id": "ABCDEFGHIJ",
  "week": [
    {
      "day": "monday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "tuesday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "wednesday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "thursday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "friday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "saturday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "sunday",
      "day_off": true
    }
  ]
}
```

**Response**

```json
{
  "message": "Schedule saved successfully",
  "status": true,
  "data": {
    "salarybox_id": "ABCDEFGHIJ",
    "schedule_type": "fixed",
    "week": [
      {
        "day": "monday",
        "day_off": false,
        "shift_names": [
          "Morning"
        ]
      },
      {
        "day": "tuesday",
        "day_off": false,
        "shift_names": [
          "Morning"
        ]
      },
      {
        "day": "wednesday",
        "day_off": false,
        "shift_names": [
          "Morning"
        ]
      },
      {
        "day": "thursday",
        "day_off": false,
        "shift_names": [
          "Morning"
        ]
      },
      {
        "day": "friday",
        "day_off": false,
        "shift_names": [
          "Morning"
        ]
      },
      {
        "day": "saturday",
        "day_off": false,
        "shift_names": [
          "Morning"
        ]
      },
      {
        "day": "sunday",
        "day_off": true,
        "shift_names": []
      }
    ]
  }
}
```

**SDK Code**

```python Example
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule"

payload = {
    "salarybox_id": "ABCDEFGHIJ",
    "week": [
        {
            "day": "monday",
            "shift_names": ["Morning"]
        },
        {
            "day": "tuesday",
            "shift_names": ["Morning"]
        },
        {
            "day": "wednesday",
            "shift_names": ["Morning"]
        },
        {
            "day": "thursday",
            "shift_names": ["Morning"]
        },
        {
            "day": "friday",
            "shift_names": ["Morning"]
        },
        {
            "day": "saturday",
            "shift_names": ["Morning"]
        },
        {
            "day": "sunday",
            "day_off": True
        }
    ]
}
headers = {
    "Authorization": "Api-Key  <apiKey>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript Example
const url = 'https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"salarybox_id":"ABCDEFGHIJ","week":[{"day":"monday","shift_names":["Morning"]},{"day":"tuesday","shift_names":["Morning"]},{"day":"wednesday","shift_names":["Morning"]},{"day":"thursday","shift_names":["Morning"]},{"day":"friday","shift_names":["Morning"]},{"day":"saturday","shift_names":["Morning"]},{"day":"sunday","day_off":true}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule"

	payload := strings.NewReader("{\n  \"salarybox_id\": \"ABCDEFGHIJ\",\n  \"week\": [\n    {\n      \"day\": \"monday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"tuesday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"wednesday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"thursday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"friday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"saturday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"sunday\",\n      \"day_off\": true\n    }\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Api-Key  <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Example
require 'uri'
require 'net/http'

url = URI("https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Api-Key  <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"salarybox_id\": \"ABCDEFGHIJ\",\n  \"week\": [\n    {\n      \"day\": \"monday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"tuesday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"wednesday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"thursday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"friday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"saturday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"sunday\",\n      \"day_off\": true\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"salarybox_id\": \"ABCDEFGHIJ\",\n  \"week\": [\n    {\n      \"day\": \"monday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"tuesday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"wednesday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"thursday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"friday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"saturday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"sunday\",\n      \"day_off\": true\n    }\n  ]\n}")
  .asString();
```

```php Example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule', [
  'body' => '{
  "salarybox_id": "ABCDEFGHIJ",
  "week": [
    {
      "day": "monday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "tuesday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "wednesday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "thursday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "friday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "saturday",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "day": "sunday",
      "day_off": true
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Example
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"salarybox_id\": \"ABCDEFGHIJ\",\n  \"week\": [\n    {\n      \"day\": \"monday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"tuesday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"wednesday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"thursday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"friday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"saturday\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"day\": \"sunday\",\n      \"day_off\": true\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "salarybox_id": "ABCDEFGHIJ",
  "week": [
    [
      "day": "monday",
      "shift_names": ["Morning"]
    ],
    [
      "day": "tuesday",
      "shift_names": ["Morning"]
    ],
    [
      "day": "wednesday",
      "shift_names": ["Morning"]
    ],
    [
      "day": "thursday",
      "shift_names": ["Morning"]
    ],
    [
      "day": "friday",
      "shift_names": ["Morning"]
    ],
    [
      "day": "saturday",
      "shift_names": ["Morning"]
    ],
    [
      "day": "sunday",
      "day_off": true
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Flexible (roster) schedule

**Request**

```json
{
  "salarybox_id": "ABCDEFGHIJ",
  "type": "flexible",
  "dates": [
    {
      "date": "2026-11-04",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "date": "2026-11-05",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "date": "2026-11-06",
      "day_off": true
    }
  ]
}
```

**Response**

```json
{
  "message": "Schedule saved successfully",
  "status": true,
  "data": {
    "salarybox_id": "ABCDEFGHIJ",
    "schedule_type": "flexible",
    "dates": [
      {
        "date": "2026-11-04",
        "day_off": false,
        "shift_names": [
          "Morning"
        ]
      },
      {
        "date": "2026-11-05",
        "day_off": false,
        "shift_names": [
          "Morning"
        ]
      },
      {
        "date": "2026-11-06",
        "day_off": true,
        "shift_names": []
      }
    ]
  }
}
```

**SDK Code**

```python Flexible (roster) schedule
import requests

url = "https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule"

payload = {
    "salarybox_id": "ABCDEFGHIJ",
    "type": "flexible",
    "dates": [
        {
            "date": "2026-11-04",
            "shift_names": ["Morning"]
        },
        {
            "date": "2026-11-05",
            "shift_names": ["Morning"]
        },
        {
            "date": "2026-11-06",
            "day_off": True
        }
    ]
}
headers = {
    "Authorization": "Api-Key  <apiKey>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript Flexible (roster) schedule
const url = 'https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Api-Key  <apiKey>', 'Content-Type': 'application/json'},
  body: '{"salarybox_id":"ABCDEFGHIJ","type":"flexible","dates":[{"date":"2026-11-04","shift_names":["Morning"]},{"date":"2026-11-05","shift_names":["Morning"]},{"date":"2026-11-06","day_off":true}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Flexible (roster) schedule
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule"

	payload := strings.NewReader("{\n  \"salarybox_id\": \"ABCDEFGHIJ\",\n  \"type\": \"flexible\",\n  \"dates\": [\n    {\n      \"date\": \"2026-11-04\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"date\": \"2026-11-05\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"date\": \"2026-11-06\",\n      \"day_off\": true\n    }\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Api-Key  <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Flexible (roster) schedule
require 'uri'
require 'net/http'

url = URI("https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Api-Key  <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"salarybox_id\": \"ABCDEFGHIJ\",\n  \"type\": \"flexible\",\n  \"dates\": [\n    {\n      \"date\": \"2026-11-04\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"date\": \"2026-11-05\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"date\": \"2026-11-06\",\n      \"day_off\": true\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Flexible (roster) schedule
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule")
  .header("Authorization", "Api-Key  <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"salarybox_id\": \"ABCDEFGHIJ\",\n  \"type\": \"flexible\",\n  \"dates\": [\n    {\n      \"date\": \"2026-11-04\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"date\": \"2026-11-05\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"date\": \"2026-11-06\",\n      \"day_off\": true\n    }\n  ]\n}")
  .asString();
```

```php Flexible (roster) schedule
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule', [
  'body' => '{
  "salarybox_id": "ABCDEFGHIJ",
  "type": "flexible",
  "dates": [
    {
      "date": "2026-11-04",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "date": "2026-11-05",
      "shift_names": [
        "Morning"
      ]
    },
    {
      "date": "2026-11-06",
      "day_off": true
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Api-Key  <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Flexible (roster) schedule
using RestSharp;

var client = new RestClient("https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Api-Key  <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"salarybox_id\": \"ABCDEFGHIJ\",\n  \"type\": \"flexible\",\n  \"dates\": [\n    {\n      \"date\": \"2026-11-04\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"date\": \"2026-11-05\",\n      \"shift_names\": [\n        \"Morning\"\n      ]\n    },\n    {\n      \"date\": \"2026-11-06\",\n      \"day_off\": true\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Flexible (roster) schedule
import Foundation

let headers = [
  "Authorization": "Api-Key  <apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "salarybox_id": "ABCDEFGHIJ",
  "type": "flexible",
  "dates": [
    [
      "date": "2026-11-04",
      "shift_names": ["Morning"]
    ],
    [
      "date": "2026-11-05",
      "shift_names": ["Morning"]
    ],
    [
      "date": "2026-11-06",
      "day_off": true
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.salaryboxapp.com/v2/customer/v1/attendance/schedule")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```