Scripts
Scripts enable Pie to interact with your application’s backend systems during test execution. They fetch specific test data, create user profiles, or access resources that would otherwise block automated testing workflows.
Understanding Scripts
What Are Scripts?
Scripts are API endpoints or server commands that Pie calls during test execution to retrieve curated data for specific test scenarios. Instead of using random or incomplete test data, scripts ensure Pie has access to the exact data your application expects.
Why Use Scripts?
Many applications require specific data conditions to test workflows effectively. Scripts solve common testing challenges by providing:
- Test Data Requirements: Valid payment credentials, user profiles with specific attributes, or pre-configured account states
- Workflow Unblocking: Bypass manual verification steps like video KYC or OTP validation
- Environment-Specific Data: Data that works in your test environment, not generic examples
- Business Logic Testing: User profiles matching specific business rules (e.g., credit scores, approval thresholds)
Common Use Cases
Financial Applications
For fintech apps testing loan approval flows, scripts fetch pre-configured user profiles with specific credit scores or financial histories that match your approval criteria.
E-commerce Platforms
When testing checkout flows, scripts provide valid payment card details that work in your test environment, allowing Pie to complete purchase workflows without real payment data.
Identity Verification
For applications with KYC requirements, scripts bypass manual verification steps or provide pre-verified user credentials, enabling automated testing of post-verification workflows.
Setting Up Scripts
Accessing the Scripts Interface
- Log in to your Pie dashboard
- Navigate to Settings from the left sidebar
- Select Scripts

Adding a New Script
- Click the + Add button
- Provide a descriptive Script Name that indicates what data the script fetches
- Enter the curl Command that calls your API endpoint
- Click Save

curl Command Requirements
Your curl command should include:
- Your server endpoint URL
- Required headers (authentication, content-type)
- Request method (GET, POST, etc.)
- Necessary request parameters
Example:
curl -X POST "https://pieshop.com/api/get-locations" \
-H "accept: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
--data "zip_code=78701"Working with Your Backend Team
Coordinate with your backend developers to ensure the curl command:
- Targets your test or staging environment, never production
- Includes proper authentication
- Returns data in a consistent format
- Handles errors appropriately
Using Scripts in Test Cases
Once configured, scripts can be referenced when creating custom test cases.
Calling a Script
When writing a custom test prompt, reference your script by name. Pie will execute the script, retrieve the data, and use it during test execution.
Example:
Create a new banking user by calling the “create-new-banking-user-2” script, then use those values in the “update-ssn” script to complete the profile setup.
Multiple Script Calls
A single test case can call multiple scripts in sequence. Reference each script by name in your prompt in the order they should execute.
Best Practices
Naming Conventions
Use clear, descriptive names that indicate what data the script fetches and its intended use case. Include version numbers when maintaining multiple variations.
Examples:
- create-banking-user
- fetch-unique-phone-number
- get-valid-debit-card
- create-prequalified-loan-user
Data Scope Management
Configure scripts to return only the specific data needed for testing. Avoid fetching entire databases or excessive information that could slow down test execution.
Environment Configuration
Ensure your test servers have:
- Appropriate test data available
- Proper authentication configured
- Error handling for missing data
Troubleshooting
Script Not Executing
If a script isn’t being called during test execution:
- Verify the script name exactly matches what’s referenced in your test prompt
- Confirm the curl command is properly formatted
- Ensure your server endpoint is accessible from Pie’s infrastructure
Authentication Errors
If you receive authentication errors:
- Verify your API token or credentials are current
- Check the authorization header is correctly formatted
- Ensure your test server accepts requests from Pie’s IP ranges
Data Not Returned
If the script executes but data isn’t being used:
- Confirm your API returns data in the expected format
- Check server logs for errors
- Verify the response isn’t being rejected by validation rules
Security Considerations
Credentials Management
- Store API tokens and authentication data securely
- Use environment-specific credentials for test servers
- Rotate credentials regularly
- Never include production credentials in test scripts
Data Isolation
- Ensure scripts only access test environment data
- Use separate databases or data partitions for testing
- Implement proper access controls on API endpoints
- Monitor script usage for unusual patterns
Related Features
Scripts work alongside other Pie features for comprehensive testing:
- Credentials Manager: Stores login credentials for different user types
- API Keys: Authenticates Pie’s access to your application
- Custom Test Cases: Uses scripts to test specific workflows
For information on these features, see their respective documentation sections.
Need Help?
Contact your Pie support team with details about your use case and testing requirements.