Attach Local Files to Submittals
This tutorial demonstrates how to attach local files to a submittal item in a Forma project. The steps include verifying the user’s permissions and gathering required fields, creating the attachment object, generating a signed S3 URL, uploading the file to the signed URL, and updating the attachment status. For more information on working with submittals, see the Help documentation.
For information about attaching files to submittals that were already uploaded to the Forma Files tool, see the Attach Files to Submittals from the Files Tool tutorial.
Before You Begin
-
Acquire a 3-legged OAuth token with
data:readdata:writescopes. -
Verify that you have access to the relevant hub and Forma project.
-
Find the relevant project ID for the project you want to create a submittal item in by following the Retrieve a Hub ID and Project ID tutorial. In this example, assume the project ID is
91b5ea71-e3ea-495b-999d-57443a8af6a4. -
This tutorial assumes an item was created in Submit state
sbc-1by a user with manager permissions. For more information on creating a submittal item, see the Create a Submittal Item tutorial. In this example, assume the submittal item ID is938eb16d-5603-4df9-adcd-00f75d48e145. -
Ensure you have assigned manager-level permissions to at least one user for the project via the UI. To assign a manager to a submittal item, you need to ensure the user has the necessary permissions and roles set within the project. For instructions on setting up roles and permissions see the Help documentation.
-
The Submittal Item workflow progresses through several sequential states. Below are the states in the UI and their equivalent API names:
Step 1: Verify Permissions and Fields
Before uploading an attachment, verify the user’s permissions and gather the mandatory and optional fields required to make the POST attachment request in step 2.
Call GET item/:id using the project ID (2570d4e5-9aef-4b41-8e45-a454f2f3fd65) and the submittal item ID (938eb16d-5603-4df9-adcd-00f75d48e145). Check the permittedActions object for Attachment::create. If this action is listed, the user has permission to create an attachment.
The permittedActions object also provides the mandatoryFields and fields arrays, which specify the required and optional parameters for the POST attachments request. Calling GET item/:id at any stage in the workflow will return the permitted actions for the user at that point for the submittal item.
Request
Response
Note the following:
-
Mandatory Fields:
> - Locate the
permittedActionsobject with"id": "Attachment::create". ThemandatoryFieldsarray specifies the required fields for creating an attachment: >
> -name: The name of the attachment. > -urnTypeId: The type of object being referenced. This field must always be included, and its value should always be2. -
Optional Fields:
> - Under the same
"id": "Attachment::create"entry, thefieldsarray lists optional parameters: >
> -categoryId: Links the attachment to a specific workflow state.
Include these fields in your POST attachment request in Step 2.
Step 2: Create an Attachment Object
Call POST attachment to create the attachment object. This step registers the attachment metadata with the submittal item but does not yet upload the file.
-
The
urnTypeIdfield must be included in the request and should always have the value2. -
The
categoryIdis typically assigned automatically based on the submittal item’s current state. In most cases, you do not need to includecategoryIdin your request. However, for specific exceptions, you must provide it explicitly:> - Prepare for Review (
mgr-1): By default, when the submittal item is in the Prepare for Review state, thecategoryIdis assigned automatically as2(for-review). If you want the attachment to be tagged as a Submit state attachment instead, you must explicitly setcategoryIdto1in the request. > - Final Response Attachments: If you are closing a submittal item from a state other than Close and Distribute (mgr-2), and you want the attachment to be marked as a final response, explicitly setcategoryIdto4. -
For items in the Review (
rev) state, include thetaskIdfield to associate the attachment with a specific task. This ensures the attachment is linked to the relevant task in the review process.
You can retrieve the full list of available categoryId values and their corresponding meanings by calling GET metadata, and reviewing the attachmentCategories list in the response.
Request
Response
Note the following:
- Attachment ID (
id): This is required for subsequent steps to update the attachment or finalize its status. - Category ID (
categoryId): Ensure it is correctly set, either automatically or manually, depending on the workflow state. - Permitted Actions: The object containing
"id": "Attachment::partial_update"in the response indicates that the user can update the attachment withisFileUploaded=true. This will be used in Step 6. - Upload URN (
uploadUrn-urn:adsk.objects:os.object:wip.dm.prod/a9d330bc-411f-4aaf-874a-9844cc002d00.pdf): Use this in Step 3 to generate a signed S3 URL for uploading the file.
The upload URN includes the following sections: <urn:adsk.objects:os.object>:<bucket key>/<object key> Note the bucket key - wip.dm.prod and the object key - a9d330bc-411f-4aaf-874a-9844cc002d00.pdf
Step 3: Generate a Signed S3 URL
Use the bucket key from the uploadUrn (wip.dm.prod) and the object key (a9d330bc-411f-4aaf-874a-9844cc002d00.pdf) to call GET signeds3upload to generate a signed URL for the storage object.
This endpoint supports generating multiple signed URLs, which allows you to upload multiple chunks of the same file in parallel. For more information, see GET signeds3upload.
Request
Response
Note the uploadKey and the urls response attributes.
Step 4: Upload a File to the Signed URL
To upload the file to the signed URL, use a PUT method and the urls attribute as the URI.
Note that you should not use a bearer token with this call.
Request
Note that a successful call (200) returns an empty response.
Step 5: Complete the Upload
Use the bucket key (wip.dm.prod), the object key (a9d330bc-411f-4aaf-874a-9844cc002d00.pdf) and the upload key (AQICAHgdUabBXKpMwUkoF5ivioCSHNq_j4g7HRbexUuX..........UbHJ5QNz9quo=) to call POST signeds3upload to complete the upload.
This endpoint needs to be called within 24 hours from the time you began uploading the file.
Request
Response
The file has been uploaded to the storage object.
Step 6: Finalize the Attachment Status
Call PATCH attachment with isFileUploaded=true to update the attachment status. This step marks the attachment as fully uploaded and ensures it is recognized as complete in the submittal workflow.
Use the id of the attachment generated in Step 2 and update the status.
Request
Response
Congratulations! You have successfully added a local attachment to a submittal item in Forma. The attachment is now part of the submittal workflow and ready for further processing or review.
Imported from the Autodesk Platform Services documentation: https://aps.autodesk.com/en/docs/acc/v1/tutorials/submittals/attach-local-files.