> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Commit Upload Session

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = localizeLink(href);
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

<RelatedLinks
  title="REQUIRED GUIDES"
  items={[
{ label: translate("Create Upload Session"), href: "/guides/uploads/chunked/create-session", badge: "GUIDE" },
{ label: translate("Upload Part"), href: "/guides/uploads/chunked/upload-part", badge: "GUIDE" }
]}
/>

The final step in a chunked upload is to commit the session.

To commit a file upload session, call the
<Link href="/reference/post-files-upload-sessions-id-commit">`POST /files/upload_sessions/:id/commit`</Link> with a list of uploaded
parts to commit.

<CodeGroup>
  ```sh cURL theme={null}
  curl -i -X POST "https://upload.box.com/2.0/files/upload_sessions/F971964745A5CD0C001BBE4E58196BFD/commit" \
       -H "authorization: Bearer <ACCESS_TOKEN>" \
       -H "digest: sha=fpRyg5eVQletdZqEKaFlqwBXJzM=" \
       -H "content-type: application/json" \
       -d '{
         "parts": [
           {
             "part_id": "BFDF5379",
             "offset": 0,
             "size": 8388608,
  	     "sha1": "134b65991ed521fcfe4724b7d814ab8ded5185dc"
           },
  		     {
             "part_id": "E8A3ED8E",
             "offset": 8388608,
             "size": 1611392,
  	     "sha1": "234b65934ed521fcfe3424b7d814ab8ded5185dc"
           }
         ],
         "attributes": {
           "content_modified_at": "2017-04-08T00:58:08Z"
         }
       }'
  ```

  ```typescript Node/TypeScript v10 theme={null}
  await client.chunkedUploads.createFileUploadSessionCommit(
    uploadSessionId,
    { parts: parts } satisfies CreateFileUploadSessionCommitRequestBody,
    { digest: digest } satisfies CreateFileUploadSessionCommitHeadersInput,
  );
  ```

  ```python Python v10 theme={null}
  client.chunked_uploads.create_file_upload_session_commit(
      upload_session_id, parts, digest
  )
  ```

  ```cs .NET v10 theme={null}
  await client.ChunkedUploads.CreateFileUploadSessionCommitAsync(uploadSessionId: uploadSessionId, requestBody: new CreateFileUploadSessionCommitRequestBody(parts: parts), headers: new CreateFileUploadSessionCommitHeaders(digest: digest));
  ```

  ```swift Swift v10 theme={null}
  try await client.chunkedUploads.createFileUploadSessionCommit(uploadSessionId: uploadSessionId, requestBody: CreateFileUploadSessionCommitRequestBody(parts: parts), headers: CreateFileUploadSessionCommitHeaders(digest: digest))
  ```

  ```java Java v10 theme={null}
  client.getChunkedUploads().createFileUploadSessionCommit(uploadSessionId, new CreateFileUploadSessionCommitRequestBody(parts), new CreateFileUploadSessionCommitHeaders(digest))
  ```

  ```java Java v5 theme={null}
  //Creates the file hash
  byte[] digestBytes = digest.digest();
  //Base64 encoding of the hash
  String digestStr = Base64.encode(digestBytes);

  //Commit the upload session. If there is a failure, abort the commit.
  BoxFile.Info fileInfo = session.commit(digestStr, parts, null, null, null);
  ```

  ```python Python v4 theme={null}
  import hashlib

  sha1 = hashlib.sha1()
  # sha1 should have been updated with all the bytes of the file

  file_atributes = {
      'description': 'A file uploaded via Chunked Upload',
  }

  upload_session = client.upload_session('11493C07ED3EABB6E59874D3A1EF3581')
  uploaded_file = upload_session.commit(sha1.digest(), file_atributes=file_atributes)
  print(f'Successfully uploaded file {uploaded_file.id} with description {uploaded_file.description}')
  ```

  ```javascript Node v4 theme={null}
  // Finalize upload session 93D9A837B45F
  client.files.commitUploadSession(
  	'93D9A837B45F',
  	fileHash.digest('base64'),
  	{description: 'A file I uploaded in chunks!'},
  	callback
  );
  ```
</CodeGroup>

<Info>
  Additionally, any file `attributes` can be passed along with the `parts` to
  further add information to the file. See the <Link href="/reference/post-files-content">`POST /files/content`</Link>
  API for more details.
</Info>

## Response

When successful, the API returns a HTTP `201 Created` status code with a
<Link href="/reference/resources/file">`File`</Link> object.

In some cases, creating the parts might not be ready yet and the API will return
a `202 Accepted` status code instead. In this case the application should check
the `retry-after` header and retry committing after the number of seconds
specified.

<RelatedLinks
  title="RELATED APIS"
  items={[
{ label: translate("Commit upload session"), href: "/reference/post-files-upload-sessions-id-commit", badge: "POST" }
]}
/>
