---
title: Upload an Audio File
slug: tutorials/upload-an-audio-file
description: Learn how to upload audio files for processing using an endpoint with this comprehensive document. It provides code examples in various languages, including cURL, Node.js, JavaScript, Python, Ruby, C#, and PHP, for making a POST request. The document also
docTags: 
createdAt: 2022-06-14T17:55:45.000Z
---

# <font color="#3694fc">//  </font>Overview&#x20;

Leveraging the unique `interactionIdentifier` provided upon successfully [declaring an audio interaction](docId\:PqLj1vqO7gTf0iqj1LBVN), this endpoint enables you to **[upload valid audio](https://docs.elevateai.com/overview#yUZ5G)** for processing directly from the host machine as a **`multipart/form-data`** request.

:::hint{type="info"}
**Pro tip**: Providing access to audio files via the **`downloadUri`** is highly recommended for [fastest processing times.](https://docs.elevateai.com/overview#CcDVe)
:::

When this <font color="#3b9f0f">`POST`</font> request successfully executes, an HTTP status is returned to indicate the request was successful and the file is in the process of being uploaded by the Service.

If an error occurs when requesting to upload interaction, a standard HTTP response code is retuned to indicate the request was unsuccessful, along with a JSON response containing additional details to [assist with troubleshooting](https://docs.elevateai.com/#Qofti).&#x20;

:::hint{type="info"}
**Remember**: You can easily retrieve the [processing status](docId\:dg0fHnxsBeEqTYD1ruQrQ) of your interaction at any time; [click here](docId\:dg0fHnxsBeEqTYD1ruQrQ) for more.
:::

***

# <font color="#23c9ff">//  </font>Request Parameters & Code Examples

:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "https://api.elevateai.com/v1/interactions/{interactionIdentifier}/upload",
  "name": "Upload an Interaction (Audio)",
  "method": "POST",
  "request": {
    "pathParameters": [],
    "queryParameters": [],
    "headerParameters": [
      {
        "kind": "required",
        "name": "X-API-Token",
        "type": "string",
        "description": "Valid API key associated with your account for authentication and usage tracking"
      }
    ],
    "bodyDataParameters": [],
    "formDataParameters": [
      {
        "kind": "required",
        "name": "filename.{extension}",
        "type": "String",
        "description": "Parameter name will include the file type extension (example: 'filename.wav') with key providing path to local file"
      }
    ]
  },
  "results": {
    "languages": [
      {
        "id": "IkVdsxIFeIysauK1UAE-R",
        "code": "",
        "language": "201",
        "customLabel": ""
      },
      {
        "id": "ogn--fHK6DTgAEYiv7jAi",
        "code": "{\n  \"errorMessage\": \"string\"\n}",
        "language": "400",
        "customLabel": ""
      },
      {
        "id": "x6cJ5u7giQEcVl-2Yh9jn",
        "code": "{\r\n  \"errorMessage\": \"string\"\r\n}",
        "language": "401",
        "customLabel": ""
      },
      {
        "id": "r7hyVo61gcH9q_qUh9YRD",
        "code": "{\r\n  \"errorMessage\": \"string\"\r\n}",
        "language": "409",
        "customLabel": ""
      },
      {
        "id": "AhEtOMRrvKLvUGtebU-xf",
        "code": "{\r\n  \"errorMessage\": \"string\"\r\n}",
        "language": "413",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "IkVdsxIFeIysauK1UAE-R"
  },
  "examples": {
    "languages": [
      {
        "id": "-KWVFEILNlxH6_RBQvV_a",
        "code": "curl --location -g --request POST 'https://api.elevateai.com/v1/interactions/{interactionIdentifier}/upload' \\\n--header 'X-API-Token: {Your-API-Token}' \\\n--form 'filename.wav=@\"/path/to/file\"'",
        "language": "curl",
        "customLabel": ""
      },
      {
        "id": "GHwoKSuH8-z_BynFz4eQK",
        "code": "var request = require('request');\nvar fs = require('fs');\nvar path = require('path');\n\nvar filepath = '/path/to/file'\n\nvar options = {\n  'method': 'POST',\n  'url': 'https://api.elevateai.com/v1/interactions/{interactionIdentifier}/upload',\n  'headers': {\n    'X-API-Token': '{Your-API-Token}'\n  },\n  formData: {\n    'filename.wav': {\n      'value': fs.createReadStream(filepath),\n      'options': {\n        'filename': path.parse(filepath).base,\n        'contentType': null\n      }\n    }\n  }\n};\nrequest(options, function (error, response) {\n  if (error) throw new Error(error);\n  console.log(response.body);\n});\n",
        "language": "nodejs",
        "customLabel": ""
      },
      {
        "id": "N9c0GDhrJpyUu1j_YucEw",
        "code": "var myHeaders = new Headers();\nmyHeaders.append(\"X-API-Token\", \"{Your-API-Token}\");\n\nvar formdata = new FormData();\nformdata.append(\"filename.wav\", fileInput.files[0], \"[PROXY]\");\n\nvar requestOptions = {\n  method: 'POST',\n  headers: myHeaders,\n  body: formdata,\n  redirect: 'follow'\n};\n\nfetch(\"https://api.elevateai.com/v1/interactions/{interactionIdentifier}/upload\", requestOptions)\n  .then(response => response.text())\n  .then(result => console.log(result))\n  .catch(error => console.log('error', error));",
        "language": "javascript",
        "customLabel": ""
      },
      {
        "id": "zeyYuZZWRN51zLfjKlgIz",
        "code": "import requests\n\nurl = \"https://api.elevateai.com/v1/interactions/{interactionIdentifier}/upload\"\n\npayload={}\nfiles=[\n  ('yourfilename.extention',('yourfilename.extention',open('/path/to/file','rb'),'application/octet-stream'))\n]\nheaders = {\n  'X-API-Token': '{Your-API-Token}'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload, files=files)\n\nprint(response.text)",
        "language": "python",
        "customLabel": ""
      },
      {
        "id": "xS0YiyE-fD9e97AY7LAd8",
        "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.elevateai.com/v1/interactions/{interactionIdentifier}/upload\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"X-API-Token\"] = \"{Your-API-Token}\"\nform_data = [['filename.wav', File.open('/path/to/file')]]\nrequest.set_form form_data, 'multipart/form-data'\nresponse = https.request(request)\nputs response.read_body",
        "language": "ruby",
        "customLabel": ""
      },
      {
        "id": "QZd-47-7Rj83c9bkaU0lm",
        "code": "var client = new RestClient(\"https://api.elevateai.com/v1/interactions/{interactionIdentifier}/upload\");\r\nclient.Timeout = -1;\r\nvar request = new RestRequest(Method.POST);\r\nrequest.AddHeader(\"X-API-Token\", \"{Your-API-Token}\");\r\nrequest.AddFile(\"filename.wav\", \"/path/to/file\");\r\nIRestResponse response = client.Execute(request);\r\nConsole.WriteLine(response.Content);",
        "language": "csharp",
        "customLabel": ""
      },
      {
        "id": "FyoeVNR8tT3npEYMf8hu7",
        "code": "<?php\r\nrequire_once 'HTTP/Request2.php';\r\n$request = new HTTP_Request2();\r\n$request->setUrl('https://api.elevateai.com/v1/interactions/{interactionIdentifier}/upload');\r\n$request->setMethod(HTTP_Request2::METHOD_POST);\r\n$request->setConfig(array(\r\n  'follow_redirects' => TRUE\r\n));\r\n$request->setHeader(array(\r\n  'X-API-Token' => '{Your-API-Token}'\r\n));\r\n$request->addUpload('filename.wav', '/path/to/file', '[PROXY]', '<Content-Type Header>');\r\ntry {\r\n  $response = $request->send();\r\n  if ($response->getStatus() == 200) {\r\n    echo $response->getBody();\r\n  }\r\n  else {\r\n    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .\r\n    $response->getReasonPhrase();\r\n  }\r\n}\r\ncatch(HTTP_Request2_Exception $e) {\r\n  echo 'Error: ' . $e->getMessage();\r\n}",
        "language": "php",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "GHwoKSuH8-z_BynFz4eQK"
  },
  "description": "",
  "currentNewParameter": {
    "label": "Header Parameter",
    "value": "headerParameters"
  },
  "autoGeneratedAnchorSlug": "upload-an-interaction-audio",
  "legacyHash": "d600pH_vRlEvvN6BvnIHq"
}
```
:::

**Need more help?** Contact the [ElevateAI Support team](mailto\:support@elevateai.com). &#x20;
