Skip to main content

Send Agent Schedules to Qvasa with the Schedule File Upload API

Send Agent Schedules to Qvasa with the Schedule File Upload API

If your agents' schedules live in another system (a WFM tool, a BPO's planner, a spreadsheet your team exports), that system can send them to Qvasa as CSV files. Qvasa imports each file seconds after it arrives, one at a time in the order they arrive, and the shifts appear on your Schedule timeline and in your adherence reporting.

The sending system proves each file is yours with an integration token: a key you make in Qvasa that can do one thing, send files to your schedule feed. It acts for your account, not for a person, so it keeps working when people come and go.

Setup is five steps in one page, and that page always opens at the step you're on. This article walks through each, and its last section is the API reference for the developer who builds the export. The same reference is published on its own, to hand to that developer with the token: Upload WFM Schedule Files with an Integration Token: API Reference for Developers.


Before you start: who can do this, and what must be on

You need to be an account admin or owner. The setup page, Settings > Integration Tokens and Settings > File Channels are shown only to admins and owners.

Two features must be turned on for your account by the Qvasa team:

  • Workforce Management (WFM), with its pages showing in the app.

  • Integration tokens.

If you don't see these, a feature is off or you aren't an admin:

  • No Schedule file upload API row on WFM > Setup > Connectors.

  • No Integration Tokens or File Channels card on Settings.

  • The setup page says "This feature is not enabled for your account", or a line at its top says integration tokens or workforce management aren't turned on.

Check with an account owner that your user is an admin, then ask your Qvasa team to turn on the feature that's missing.

Optional: Schedule Code Mappings. If the sending system uses its own names for activities (say mat_leave where you say Unavailable), mappings make its rows land on your own schedule codes. The Qvasa team makes the feature available, then an admin switches it on in WFM > Setup > Features. Without it, every code a file sends becomes a schedule code of its own.


1. Make the schedule feed

Go to WFM > Setup > Connectors and open Schedule file upload API. The page lists the five steps.

The feed is where your system sends schedule files. If you only want agents from one company imported, enter their email domain in Agents' email domain (for example yourcompany.com). Rows for other addresses are skipped. Then click Make the feed.

The step turns green and names the feed's file channel, wfm-schedules. That name is part of the address your system sends files to.


2. Make an integration token for each system that sends files

In step 2, click Make a token for the feed. The New integration token form opens with everything the feed needs already filled in:

  • Name: "WFM schedule files sender". Rename it after the system that will hold it, such as "Manila BPO planner", so you know which token is which later.

  • Grants: Send files to named channels is on, with WFM schedule files ticked. That's the only thing this token can do. It can't read any of your data.

  • Per minute / Per day: how many requests the token may make, 600 a minute and 20,000 a day by default. A file sent in one request is one request.

  • Expires: 90 days by default. Choose Never, a period or a date. An admin is emailed 30 and 7 days before a token expires.

  • IP ranges (optional): the addresses the sending system calls from. Requests from anywhere else are refused.

Click Create token. The token's page shows its secret, which starts with qva_int_. Copy it now: it's shown only once. Qvasa keeps only a fingerprint of it, so nobody can read it back. Give the secret to whoever configures the sending system, through your password manager or another safe channel.

More than one sending system? Make one token for each: for example, one for each BPO site that sends its own agents' schedules. Click Make a token for the feed again, or go to Settings > Integration Tokens, click New integration token, turn on Send files to named channels and tick WFM schedule files. Several systems can share one feed because a file only changes the schedules of the agents in it (see "What a file changes" below). Separate tokens let you see which system sent each file, and revoke one without stopping the others. An account can have up to 50 active tokens.

Later, from Settings > Integration Tokens:

  • Roll secret issues a new secret and keeps the old one working for the time you choose (now, 1 hour, 24 hours or 7 days), so the system can switch over without an outage.

  • Revoke token stops it at once.

  • Each token's page shows when it was last used, from which address, and its activity.


3. Map codes (optional)

If the sending system's activity codes aren't the same as your schedule codes, click Map codes before the first file arrives. Enter each incoming code and pick the schedule code it lands on: CHAT to Messaging, BRK to Break, mat_leave to Unavailable. Codes are matched without regard to case.

A code with no mapping isn't lost: the import makes it a schedule code of its own and lists it under Codes to Review on WFM > Setup > Code Mappings, where you keep it or merge it into one of yours. Your mappings are listed on the same page. This step never blocks the others. If Schedule Code Mappings is off, the step says so and who can turn it on.


4. Get the template, and give it to your developer

Every file is a CSV in Qvasa's schedule import template. Step 4's Download the template button downloads it: a CSV with the header row and example rows. It's the same format Qvasa reads for a schedule spreadsheet uploaded by hand, so one export serves both. Give the template, and the rest of this article, to whoever builds the export.

The columns, as the first row, in this order:

  • agent_email: the agent's email address, as Qvasa knows it. An address Qvasa hasn't seen before creates the agent.

  • activity_code: what the agent is scheduled to do (Messaging, Talk, Break, Training, or the system's own code if you mapped it in step 3).

  • date: the date the segment starts, as YYYY-MM-DD, in UTC.

  • start_time: when the segment starts, as HH:MM (24-hour), in UTC.

  • end_time: when it ends, HH:MM, in UTC. For a segment that runs past midnight, use an end time earlier than the start time (22:00 to 02:00): it ends the next day.

  • agent_name (optional, last): the name a new agent is created with. Without it, a new agent is named by their email.

One row per scheduled segment: a shift with a lunch break is three rows. For example:

agent_email,activity_code,date,start_time,end_time,agent_name
[email protected],Messaging,2026-12-01,14:00,18:00,Maya Chen
[email protected],Lunch,2026-12-01,18:00,18:30,Maya Chen
[email protected],Messaging,2026-12-01,18:30,22:00,Maya Chen
[email protected],Talk,2026-12-01,22:00,02:00,Sam Okafor
[email protected],,,,,Jonas Berg

Times are UTC, not your account's time zone. If your team works 9:00 to 17:00 Pacific, the file says 17:00 to 01:00 in winter. Convert in the export, not by hand.

What a file changes. For each agent in the file, Qvasa replaces that agent's schedule from the start of their first shift in the file to the end of their last. Agents who aren't in the file keep their schedule, past shifts are never changed, and neither are an agent's shifts before their first row or after their last. Shifts the agent got some other way (another connector, or edits in Qvasa) aren't touched. So each system can send only its own agents, and a file can cover one day or several weeks.

Clearing an agent's schedule. Send one row with only their email (and name) filled in, like Jonas's row above: every future shift this feed gave them is removed.

Limits. A file can be up to 100 MB and 500,000 rows, and no shift in it may end more than 366 days from now. It must be UTF-8 text. A file in which more rows fail to read than succeed isn't imported at all.


5. Send a file

The sending system makes one HTTPS request per file. Your feed's address, the request and an example are also on the feed's page: click How to send a file in step 4, or open Settings > File Channels > WFM schedule files.

curl -X POST https://www.qvasa.com/api/integrations/v1/file_channels/wfm-schedules/files \
  -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN" \
  -H "Content-Type: text/csv" \
  -H "X-Qvasa-Filename: schedule_2026-12-01.csv" \
  -H "X-Qvasa-Content-Sha256: $(shasum -a 256 schedule_2026-12-01.csv | cut -d' ' -f1)" \
  -H "Idempotency-Key: $(shasum -a 256 schedule_2026-12-01.csv | cut -d' ' -f1)" \
  --data-binary @schedule_2026-12-01.csv

  • Authorization: Bearer, a space, then the token's secret.

  • X-Qvasa-Content-Sha256 (required): the file's SHA-256, in hex. Qvasa checks it and refuses a file that changed on the way.

  • X-Qvasa-Filename: the name you'll see on the setup page and the channel's file list.

  • Idempotency-Key (optional, recommended): lets the system retry a request safely. If a request times out and is sent again with the same key, the file isn't imported twice. Use a value that's different for every file, such as the file's SHA-256 as above. A key used again within 24 hours for a different file is refused.

  • Files over 25 MB go in 8 MiB parts through an upload session. The feed's page shows those requests.

Qvasa answers 201 Created with the file's id and "status": "received". To see what the import did, the system reads the file back:

curl https://www.qvasa.com/api/integrations/v1/file_channels/wfm-schedules/files/1234 \
  -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN"

Its status moves from received to processing, then to processed or failed. A failed file carries a failure_reason in plain words, and changed nothing. A processed file's processing_summary counts the rows, the agents created, the codes mapped and created, and the shifts written.

Files run one at a time, oldest first, so a feed that sends often never imports an older schedule over a newer one. Qvasa deletes each file's contents once its import ends; its details and summary stay readable.


6. Check what the latest file did

Back on the setup page, step 5 shows the latest file and what it did. When every step is green, the page reads Setup complete.

  • Rows imported and Rows unreadable: how many rows were read, and how many couldn't be.

  • Agents cleared: agents whose schedule a clear row removed.

  • Last shift ends: the end of the latest shift in the file, in your account's time zone.

  • Schedule timeline opens the shifts. Import runs lists every file's import.

If the file made new schedule codes (codes with no mapping), they wait under Codes to Review on WFM > Setup > Code Mappings.


Troubleshooting

  • 401, and the file isn't listed anywhere. The token's secret is missing, mistyped, revoked or expired. Check the Authorization header, or make a new token.

  • 403 channel_not_granted. The token can't send to this feed. Edit the token in Settings > Integration Tokens and tick WFM schedule files under Send files to named channels.

  • 403 ip_address_not_allowed. The request came from outside the token's IP ranges. Add the sending system's addresses to the token.

  • 403 integration_tokens_not_enabled. Integration tokens are off for the account. Ask your Qvasa team.

  • 409 file_channel_feature_off or file_channel_has_no_workflow. Workforce Management was turned off for the account, or the feed's workflow was deleted. Nothing was stored. Ask your Qvasa team, or set the feed up again.

  • 422 idempotency_key_reused. The same Idempotency-Key was sent with a different file within 24 hours. Use a key that's unique to each file.

  • 429. The token went over its requests per minute or per day. Wait for the time in the Retry-After header, or raise the limit on the token.

  • The file is failed. Read its failure_reason (also on step 5 and the channel's file list): a missing or misspelled header, a date or time Qvasa can't read, a file over the limits. Fix the export and send it again.

  • Shifts are hours off. The export is sending local times. Times in the file are UTC.

  • An agent's rows were skipped. Their email isn't in the feed's agents' email domain.


For developers: API reference

Everything the sending system needs: the token, the file format, every call, what each answers, and every error. It is also published on its own as Upload WFM Schedule Files with an Integration Token: API Reference for Developers.

What you need

  • An integration token's secret, from your Qvasa admin. It starts with qva_int_. Keep it in a secrets store: it can't be shown again, only replaced.

  • The channel's name (its slug), usually wfm-schedules. Your admin sees it on the setup page and on Settings > File Channels.

  • The base URL: https://www.qvasa.com/api/integrations/v1. Every call is HTTPS.

Every request carries the secret as a Bearer token:

Authorization: Bearer qva_int_...

What the token can and can't do

  • It acts for the Qvasa account, not for a person, and keeps working when people leave.

  • It can do only what its admin granted. For schedule files that's Send files to named channels, limited to the channels the admin ticked. It can send files to those channels, read back the files on them, and read its own details. It can't read your Qvasa data, download a file, or call any other Qvasa API.

  • It may have an expiry date and a list of IP addresses it works from. Requests from anywhere else are refused.

  • It has request limits, 600 a minute and 20,000 a day by default. Every call counts, status reads and parts included.

  • An admin can roll its secret (the old and new secrets both work for an overlap the admin chooses, so you can switch without an outage) or revoke it at once.

Check the token

Every live token can read its own details. It's a good first call: it proves the secret, the network rules and the grants before you build on them.

curl https://www.qvasa.com/api/integrations/v1/token \
  -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN"

{
  "token": {
    "id": 42,
    "name": "Manila BPO planner",
    "account_id": 1290,
    "secret": "qva_int_KkLr...zI8R",
    "secret_expires_at": null,
    "expires_at": "2027-02-28T22:43:00Z",
    "allowed_ip_ranges": [],
    "grants": [
      { "key": "file_channels.upload", "name": "Send files to named channels",
        "requests_per_minute": 600, "requests_per_day": 20000,
        "lifetime_request_cap": null, "lifetime_requests_counted": null }
    ]
  }
}

secret is a shortened form, never the whole secret. secret_expires_at is set when an admin has rolled the secret you're using: it stops working then, so switch to the new one first. A null expires_at means the token never expires.

The file format

A file is a CSV in Qvasa's schedule import template, UTF-8, with a header row. Your admin can download the template from the setup page's Download the template. The columns, in this order:

Column

Format

Meaning

agent_email

email

The agent, by their email in Qvasa (their Zendesk email). A new address creates the agent.

activity_code

text

What the agent is scheduled to do. Your own codes are fine: an admin maps them to Qvasa's schedule codes, and a code with no mapping becomes a new code.

date

YYYY-MM-DD, UTC

The day the segment starts.

start_time

HH:MM, 24-hour, UTC

When the segment starts.

end_time

HH:MM, 24-hour, UTC

When it ends. An end earlier than the start ends the next day (22:00 to 02:00).

agent_name (optional, last)

text

The name a new agent is created with.

agent_email,activity_code,date,start_time,end_time,agent_name
[email protected],CHAT,2026-12-01,14:00,18:00,Maya Chen
[email protected],LUNCH,2026-12-01,18:00,18:30,Maya Chen
[email protected],CHAT,2026-12-01,18:30,22:00,Maya Chen
[email protected],PHONE,2026-12-01,22:00,02:00,Sam Okafor
[email protected],,,,,Jonas Berg

  • One row per segment. A shift with a lunch is three rows.

  • All dates and times are UTC. Convert from local time in your export, daylight saving included.

  • What a file replaces: for each agent in the file, their schedule from the start of their first segment in the file to the end of their last. Agents not in the file, past shifts, and an agent's shifts outside that span are left as they are, as are shifts from other sources. So a file can cover one day or several weeks, and several systems can send their own agents to one channel.

  • A clear row (an email with every other cell blank, like Jonas above) removes every future shift this channel gave that agent.

  • To send a change, send the agent's whole span again. There are no per-row updates or deletes: the file is the schedule for each agent it names.

  • Limits: up to 100 MB and 500,000 rows. No shift may end more than 366 days from now.

Send a file in one request (up to 25 MB)

POST /file_channels/{channel}/files with the file's bytes as the body.

FILE=schedule_2026-12-01.csv
SHA=$(shasum -a 256 "$FILE" | cut -d' ' -f1)
curl -X POST https://www.qvasa.com/api/integrations/v1/file_channels/wfm-schedules/files \
  -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN" \
  -H "Content-Type: text/csv" \
  -H "X-Qvasa-Filename: $FILE" \
  -H "X-Qvasa-Content-Sha256: $SHA" \
  -H "Idempotency-Key: $SHA" \
  --data-binary @"$FILE"

Header

What it does

Authorization

required

Bearer and the token's secret.

Content-Type

required

text/csv. Qvasa also checks the bytes: a file that isn't CSV is refused.

X-Qvasa-Content-Sha256

required

The body's SHA-256, as 64 hex characters or base64. A body that doesn't match is refused and nothing is stored.

X-Qvasa-Filename

recommended

The file's name, shown to admins. Percent-encode anything outside plain ASCII.

Idempotency-Key

recommended

Makes a retry safe (below). Unique to each file: the file's SHA-256 is a good key.

201 Created means Qvasa has stored the file and queued its import:

{
  "file": {
    "id": 1234,
    "channel": "wfm-schedules",
    "filename": "schedule_2026-12-01.csv",
    "content_type": "text/csv",
    "size_bytes": 7421,
    "sha256": "cc5cb430...",
    "status": "received",
    "failure_reason": null,
    "processing_summary": null,
    "received_at": "2026-11-30T21:44:22.239Z",
    "processed_at": null,
    "expires_at": "2026-12-30T21:44:22Z",
    "created_at": "2026-11-30T21:44:22.414Z"
  }
}

Keep file.id: it's how you read what the import did.

Read what the import did

GET /file_channels/{channel}/files/{id} answers the same file object, now further along. Read it every few seconds until status is processed or failed; a file usually settles within seconds of arriving.

curl https://www.qvasa.com/api/integrations/v1/file_channels/wfm-schedules/files/1234 \
  -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN"

status

Meaning

receiving

An upload in parts that isn't complete yet.

received

Stored and waiting its turn.

processing

Being imported.

processed

Imported. processing_summary says what changed.

failed

Not imported, and nothing changed. failure_reason says why. Fix the file and send it again.

expired

An upload that was abandoned or aborted before it completed.

A processed file's summary:

"processing_summary": {
  "window_start": "2026-11-30T21:44:23Z",
  "window_end": "2026-12-04T00:00:00Z",
  "csv_rows_parsed": 108,
  "csv_clear_rows": 0,
  "csv_row_error_count": 0,
  "csv_row_errors": [],
  "activities": { "created": 2, "updated": 0, "total": 2, "mapped": 4 },
  "people": { "matched_by_wfm_id": 0, "matched_by_email": 0, "created": 8,
              "conflicts": 0, "skipped_wrong_email_domain": 0 },
  "schedule_records": { "created": 108, "updated": 0, "deleted": 0, "agents_cleared": 0,
                        "skipped_unknown_agent": 0, "skipped_unknown_activity_type": 0,
                        "sync_source_claimed": 8, "sync_source_conflict_count": 0 },
  "online_durations": { "examined": 0, "updated": 0 }
}

  • Rows that can't be read are skipped and listed in csv_row_errors (line number and reason, never the row's contents), as long as fewer rows fail than succeed. If more fail, or the header row is wrong, the whole file fails.

  • activities.mapped counts codes that landed on the admin's mappings; activities.created counts new codes, which wait for an admin to review.

  • people.skipped_wrong_email_domain counts agents outside the email domain the admin set on the feed. Their rows were skipped.

  • schedule_records.sync_source_conflict_count counts agents whose schedule another source owns. Their rows weren't written; an admin decides which source owns them.

Some failure_reason examples: "the feed's header row is missing [\"end_time\"]", "the feed is not UTF-8 text", "12 of the feed's 20 rows could not be parsed (first failing line 3)", "the feed runs to 2028-01-04, more than 366 days ahead". Each ends with "so nothing was reconciled": no schedule changed.

How files are processed

  • One at a time, oldest first, on each channel. A file never runs before one received ahead of it, and none is skipped, so a newer schedule is never overwritten by an older one that arrived first.

  • Usually within seconds. If Qvasa is busy it retries every 30 seconds; a file still waiting after an hour fails, and Qvasa is alerted.

  • The bytes are deleted once the import ends, processed or failed. The file's record and summary stay readable by its id. Nobody can download a file, not even an admin.

  • Sending the same schedule twice is harmless: the second import finds every shift already there.

Larger files: upload in parts

A file over 25 MB goes through an upload session: open it, send the parts, complete it. The same session lets you resume a broken upload.

1. Open: POST /file_channels/{channel}/uploads with a JSON body.

curl -X POST https://www.qvasa.com/api/integrations/v1/file_channels/wfm-schedules/uploads \
  -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $SHA" \
  -d '{"filename":"big.csv","size_bytes":62914560,"content_type":"text/csv","sha256":"'$SHA'"}'

filename, size_bytes (exact) and content_type are required; sha256 of the whole file is optional, and when given, Qvasa checks the assembled file against it. 201 answers the session:

{
  "upload": {
    "id": 77,
    "state": "open",
    "part_size_bytes": 8388608,
    "declared_size_bytes": 62914560,
    "expected_parts": 8,
    "parts_received": [],
    "parts_missing": [1, 2, 3, 4, 5, 6, 7, 8],
    "expires_at": "2026-12-01T21:44:22Z",
    "file": { "id": 1235, "status": "receiving", ... }
  }
}

2. Send each part: PUT /file_channels/{channel}/uploads/{id}/parts/{n}, numbered from 1, with the part's bytes as the body and its own SHA-256 in X-Qvasa-Content-Sha256.

split -b 8388608 big.csv part.
curl -X PUT https://www.qvasa.com/api/integrations/v1/file_channels/wfm-schedules/uploads/77/parts/1 \
  -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN" \
  -H "Content-Type: application/octet-stream" \
  -H "X-Qvasa-Content-Sha256: $(shasum -a 256 part.aa | cut -d' ' -f1)" \
  --data-binary @part.aa

  • Every part except the last is exactly part_size_bytes (8 MiB); the last is the remainder.

  • Parts can go in any order, and in parallel.

  • Sending a part number again replaces it, so retrying a failed part is safe.

  • Each answer is the session again, with parts_received and parts_missing. To resume after a crash, GET /file_channels/{channel}/uploads/{id} and send what's missing.

3. Complete: POST /file_channels/{channel}/uploads/{id}/complete. 202 Accepted: Qvasa assembles and checks the file, then imports it like a one-request file. Read upload.file.id as in "Read what the import did". A session with parts missing is refused (422) and stays open.

To give up: DELETE /file_channels/{channel}/uploads/{id} (204). A session left open expires 24 hours after it opened. A token can have 10 sessions open at once.

Retries and the Idempotency-Key

  • Send an Idempotency-Key (1 to 255 printable ASCII characters) on POST …/files and POST …/uploads. If the first request succeeded and you send it again with the same key within 24 hours, Qvasa answers the first response again, with the header Idempotent-Replayed: true, and stores no second file.

  • A key used again with a different file is refused (422 idempotency_key_reused). Never reuse a key for a new file: a key made from the date, for example, breaks the second file sent that day. Use the file's SHA-256.

  • A failed request (4xx or 5xx) isn't remembered, so a retry with the same key runs again.

  • Parts, complete and status reads are already safe to repeat and take no key.

  • Retry a 429 after the Retry-After seconds, and a 500 or a network error with backoff. Don't retry other 4xx answers unchanged: fix what the message says.

Limits

Limit

Value

One request

25 MB; larger files go in parts

A schedule file

100 MB, 500,000 rows, no shift ending more than 366 days from now

Part size

8 MiB (8,388,608 bytes), the last part smaller

Open uploads

10 per token; each expires after 24 hours

Requests

600 a minute and 20,000 a day per token by default (an admin can change them); every call counts

Bytes received

20 GB per account per day (UTC)

Idempotency-Key

Remembered for 24 hours

Errors

Every error answers JSON with a sentence and a stable code:

{ "error": "This file is application/zip; the channel accepts text/csv.", "error_code": "content_type_not_accepted" }

Act on error_code; show error to a person.

Status

error_code

What to do

400

checksum_required, checksum_mismatch, checksum_malformed

Send the SHA-256 of exactly the bytes in the body.

400

empty_body, size_required, part_number_out_of_range, part_size_mismatch, idempotency_key_malformed, bad_request

Fix the request as the message says.

401

integration_token_missing, integration_token_unrecognized

No token, or one that's mistyped, revoked or expired. Ask your admin for a working secret.

403

channel_not_granted, grant_required

The token isn't allowed this channel. Your admin ticks it on the token.

403

ip_address_not_allowed

You're calling from an address outside the token's IP ranges. Your admin adds yours.

403

integration_tokens_not_enabled, lifetime_request_cap_reached

Ask your admin.

404

file_channel_not_found, file_not_found, upload_not_found

Check the channel name and the id. An upload is visible only to the token that opened it.

409

file_channel_feature_off, file_channel_has_no_workflow

The channel can't import files right now, so nothing was stored. Ask your admin.

409

idempotency_in_progress

The first request with this key is still running. Retry in a few seconds.

410

file_channel_archived

The channel takes no files. Ask your admin.

410

upload_expired, upload_aborted, upload_completed

That upload has ended. Open a new one.

413

content_too_large

Over 25 MB in one request: upload in parts. Over 100 MB: split the schedule into several files (by agent, so each file holds each agent's whole span).

415

content_type_not_accepted

Send text/csv, and CSV bytes.

422

idempotency_key_reused

Use a new key for a new file.

422

upload_incomplete

Send the parts in parts_missing, then complete again.

429

rate_limited, daily_byte_cap_reached, too_many_open_uploads

Wait for Retry-After seconds (when sent), or complete or abort an open upload.

500

internal_error

Our side; we're alerted. Retry with backoff, with the same Idempotency-Key.

A complete example

Send a file and wait for its import, in bash (needs curl and jq):

#!/usr/bin/env bash
set -euo pipefail
BASE=https://www.qvasa.com/api/integrations/v1/file_channels/wfm-schedules
FILE="$1"
SHA=$(shasum -a 256 "$FILE" | cut -d' ' -f1)RESPONSE=$(curl -sS -X POST "$BASE/files" \
  -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN" \
  -H "Content-Type: text/csv" \
  -H "X-Qvasa-Filename: $(basename "$FILE")" \
  -H "X-Qvasa-Content-Sha256: $SHA" \
  -H "Idempotency-Key: $SHA" \
  --data-binary @"$FILE")
ID=$(echo "$RESPONSE" | jq -er '.file.id') || { echo "$RESPONSE"; exit 1; }for _ in $(seq 1 60); do
  FILE_JSON=$(curl -sS "$BASE/files/$ID" -H "Authorization: Bearer $QVASA_INTEGRATION_TOKEN")
  STATUS=$(echo "$FILE_JSON" | jq -r '.file.status')
  case "$STATUS" in
    processed) echo "$FILE_JSON" | jq '.file.processing_summary'; exit 0 ;;
    failed)    echo "$FILE_JSON" | jq -r '.file.failure_reason'; exit 1 ;;
  esac
  sleep 5
done
echo "still $STATUS after 5 minutes"; exit 1

Did this answer your question?