Setting computed field values in Zapier CLI application

I’m working on a Zapier CLI app and running into an issue with computed fields. I have a create operation that includes several input fields. One of these fields is marked as computed, and I need to populate it with data from a previous API request.

The problem is I’m not sure how to actually assign the value I retrieved earlier to this computed field. The field is required, but since it’s computed, users shouldn’t enter it manually. Instead, I want to set it programmatically.

Here’s my current setup:

create: {
    display: {
        label: 'Add Customer',
        description: 'Creates a customer record.',
    },
    operation: {
        inputFields: [
            {key: 'owner_id', required: true, type: 'integer', label: 'Owner', dynamic: 'owner.id.name'},
            {key: 'api_token', required: true, type: 'string', label: 'API Token', computed: true},
            {key: 'street_address', required: true, type: 'text', label: 'Street Address'}
        ],
        perform: addCustomer,
        sample: exampleData
    },
}

What’s the correct way to populate the computed field with my fetched value?

You can handle this right in the field definition using a function for the computed field. Don’t just set computed: true - define the computation logic directly in the inputFields array. Use something like {key: 'api_token', required: true, type: 'string', label: 'API Token', computed: true, altersDynamicFields: false} with a separate inputField function that returns a promise. This keeps your perform function way cleaner since the computed value gets resolved before the main operation runs. I’ve found this works great for fields that need external API calls - it’s much cleaner than modifying bundle.inputData inside perform.

Handle this in your perform function using the bundle object. Grab data from your previous API request and assign it directly to the computed field before processing the main operation. For example, if you’re fetching an API token from another endpoint, you can use const tokenResponse = await z.request(tokenOptions) and then set bundle.inputData.api_token = tokenResponse.data.token. This approach populates the computed field without user input while maintaining the validation rules. I’ve successfully implemented this pattern in multiple production Zapier apps, and it effectively manages edge cases, particularly ensuring the computed value is validated before executing the primary API call.

set computed field values in bundle.inputData inside your perform function. just add bundle.inputData.api_token = yourFetchedValue before your main api call. works every time.