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

# Create job work artifacts

> Attach files to a job work

Attach one or more files (artifacts) to a job work. Artifacts represent documents, forms, or other files associated with a tax preparation. You can create multiple artifacts in a single request.

```graphql theme={null}
mutation CreateJobWorkArtifacts($jobWorkId: ID!, $inputs: [CreateJobWorkArtifactsInput!]!) {
  createJobWorkArtifacts(jobWorkId: $jobWorkId, inputs: $inputs) {
    id
    createdAt
    updatedAt
    workspaceId
    artifactId
    connectionJobId
    workArtifact {
      id
      externalId
    }
  }
}
```

## Arguments

<ParamField path="jobWorkId" type="ID!" required>
  The ID of the job work returned from [createJobWorks](/legacy/apis/endpoint/create-works). This identifies which client/tax preparation to attach files to.
</ParamField>

<ParamField path="inputs" type="[CreateJobWorkArtifactsInput!]!" required>
  Array of artifact inputs. Each input represents one file to attach to the job work.

  <Expandable title="CreateJobWorkArtifactsInput">
    <ParamField path="inputs[].name" type="String!" required>
      File name or descriptive identifier for the artifact (e.g., "W-2 Form", "1099-INT", "receipts.pdf").
    </ParamField>

    <ParamField path="inputs[].type" type="String!" required>
      Type or category of the artifact (e.g., "w2", "1099", "receipt", "document", "form").
    </ParamField>

    <ParamField path="inputs[].url" type="String">
      Optional URL where the file can be accessed. This should be a publicly accessible URL or a URL that Filed can access using the connection credentials.
    </ParamField>

    <ParamField path="inputs[].externalId" type="String!" required>
      Your platform's unique identifier for this file/artifact. Used to correlate the artifact with your system.
    </ParamField>

    <ParamField path="inputs[].metadata" type="JSON">
      Optional metadata about the artifact. Can include file size, mime type, upload date, or any other relevant information.
    </ParamField>
  </Expandable>
</ParamField>

## Returns

<ResponseField name="id" type="ID!">
  Job artifact identifier.
</ResponseField>

<ResponseField name="createdAt" type="Date!">
  Timestamp when the job artifact was created.
</ResponseField>

<ResponseField name="updatedAt" type="Date!">
  Timestamp when the job artifact was last updated.
</ResponseField>

<ResponseField name="workspaceId" type="ID!">
  The workspace ID this job artifact belongs to.
</ResponseField>

<ResponseField name="artifactId" type="ID!">
  The artifact ID this job artifact references.
</ResponseField>

<ResponseField name="connectionJobId" type="ID!">
  The connection job ID this job artifact belongs to.
</ResponseField>

<ResponseField name="workArtifact" type="WorkArtifact!">
  The work artifact associated with this job artifact.

  <Expandable title="WorkArtifact fields">
    <ResponseField name="workArtifact.id" type="ID!">
      The unique identifier of the work artifact.
    </ResponseField>

    <ResponseField name="workArtifact.externalId" type="String!">
      The external identifier you provided when creating the artifact. This matches the `externalId` from your input.
    </ResponseField>
  </Expandable>
</ResponseField>

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://gateway.filed.com/graphql \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <accessToken>" \
    -H "source-platform: my-sample-platform" \
    -d '{
      "query": "mutation CreateJobWorkArtifacts($jobWorkId: ID!, $inputs: [CreateJobWorkArtifactsInput!]!) { createJobWorkArtifacts(jobWorkId: $jobWorkId, inputs: $inputs) { id createdAt updatedAt workspaceId artifactId connectionJobId workArtifact { id externalId } } }",
      "variables": {
        "jobWorkId": "job_work_789",
        "inputs": [
          {
            "name": "W-2 Form 2024",
            "type": "w2",
            "url": "https://api.example.com/files/w2-2024.pdf",
            "externalId": "file-12345",
            "metadata": {
              "fileSize": 245678,
              "mimeType": "application/pdf",
              "uploadDate": "2024-01-10T08:00:00Z"
            }
          },
          {
            "name": "1099-INT Statement",
            "type": "1099",
            "url": "https://api.example.com/files/1099-int.pdf",
            "externalId": "file-67890",
            "metadata": {
              "fileSize": 189234,
              "mimeType": "application/pdf"
            }
          }
        ]
      }
    }'
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "data": {
      "createJobWorkArtifacts": [
        {
          "id": "job_artifact_456",
          "createdAt": "2024-01-15T10:40:00Z",
          "updatedAt": "2024-01-15T10:40:00Z",
          "workspaceId": "workspace_123456",
          "artifactId": "artifact_456",
          "connectionJobId": "job_123456",
          "workArtifact": {
            "id": "artifact_456",
            "externalId": "file-12345"
          }
        }
      ]
    }
  }
  ```
</ResponseExample>

<Warning>
  **File URL Accessibility**: Ensure the URLs you provide are accessible to Filed. If your files require authentication, Filed will use the connection credentials provided during the connection setup. Test that Filed can access the URLs using those credentials.
</Warning>

<Note>
  The `url` field should point to a file that Filed can download. Filed will fetch the file from this URL when processing the work. Ensure the URL is valid and the file is accessible at the time of import.
</Note>

## Troubleshooting

**Problem**: Artifacts created but files cannot be accessed

**Solutions**:

* Verify the URLs are publicly accessible or accessible with the connection credentials
* Test the URLs manually to ensure they return the expected files
* Check that file URLs haven't expired or been moved
* Ensure the connection credentials have permission to access the file URLs

**Problem**: Invalid URL format

**Solutions**:

* Ensure URLs use valid protocols (https\:// or http\://)
* Verify URLs are properly encoded if they contain special characters
* Check that URLs point to actual files, not directories or API endpoints that require additional parameters
