Documentation Index Fetch the complete documentation index at: https://mintlify.com/auth0/go-auth0/llms.txt
Use this file to discover all available pages before exploring further.
Jobs represent long-running operations in Auth0, such as user imports, exports, and verification emails. Use these methods to track and manage job execution.
Get Job
Retrieve the status and details of a job.
func ( c * Client ) Get (
ctx context . Context ,
id string ,
opts ... option . RequestOption ,
) ( * management . GetJobResponseContent , error )
*management.GetJobResponseContent
Job details including status and progress Unique identifier for the job
Current status: pending, processing, completed, failed
Job type: users_export, users_import, verification_email, etc.
Connection ID if applicable
URL to download results (for completed export jobs)
Completion percentage (0-100)
Estimated time remaining in seconds
File format for export jobs (csv, json)
Summary of operations performed Number of failed operations
Number of updated records
Number of inserted records
Total number of operations
Example
job , err := managementClient . Jobs . Get ( context . Background (), "job_abc123" )
if err != nil {
// Handle error
}
fmt . Printf ( "Job status: %s \n " , job . GetStatus ())
fmt . Printf ( "Progress: %d%% \n " , job . GetPercentageDone ())
if job . GetStatus () == "completed" {
fmt . Printf ( "Download results: %s \n " , job . GetLocation ())
}
Sub-resources
The Jobs client provides access to specific job types:
Users Exports
Export users from Auth0. Access via managementClient.Jobs.UsersExports.
// Start a user export job
job , err := managementClient . Jobs . UsersExports . Create ( context . Background (), & management . CreateUsersExportRequest {
ConnectionID : auth0 . String ( "con_abc123" ),
Format : auth0 . String ( "json" ),
Fields : [] management . ExportField {
{ Name : auth0 . String ( "user_id" )},
{ Name : auth0 . String ( "email" )},
{ Name : auth0 . String ( "name" )},
},
})
if err != nil {
// Handle error
}
fmt . Printf ( "Export job started: %s \n " , job . GetID ())
Users Imports
Import users into Auth0. Access via managementClient.Jobs.UsersImports.
// Start a user import job
file , _ := os . Open ( "users.json" )
defer file . Close ()
job , err := managementClient . Jobs . UsersImports . Create ( context . Background (), & management . CreateUsersImportRequest {
ConnectionID : auth0 . String ( "con_abc123" ),
Users : file ,
Upsert : auth0 . Bool ( true ),
SendCompletionEmail : auth0 . Bool ( true ),
})
if err != nil {
// Handle error
}
fmt . Printf ( "Import job started: %s \n " , job . GetID ())
Verification Emails
Send verification emails. Access via managementClient.Jobs.VerificationEmail.
// Send a verification email
job , err := managementClient . Jobs . VerificationEmail . Create ( context . Background (), & management . CreateVerificationEmailRequest {
UserID : auth0 . String ( "auth0|abc123" ),
ClientID : auth0 . String ( "client_abc123" ),
})
if err != nil {
// Handle error
}
fmt . Printf ( "Verification email job: %s \n " , job . GetID ())
Job Errors
Retrieve errors for a failed job. Access via managementClient.Jobs.Errors.
// Get errors for a failed job
errors , err := managementClient . Jobs . Errors . List ( context . Background (), "job_abc123" )
if err != nil {
// Handle error
}
for _ , jobError := range errors {
fmt . Printf ( "Error: %s \n " , jobError . GetMessage ())
}
Polling for Job Completion
Here’s an example of polling a job until it completes:
package main
import (
" context "
" fmt "
" log "
" time "
" github.com/auth0/go-auth0/v2/management "
)
func waitForJob ( ctx context . Context , client * management . Client , jobID string ) ( * management . GetJobResponseContent , error ) {
ticker := time . NewTicker ( 5 * time . Second )
defer ticker . Stop ()
timeout := time . After ( 10 * time . Minute )
for {
select {
case <- timeout :
return nil , fmt . Errorf ( "job timeout" )
case <- ticker . C :
job , err := client . Jobs . Get ( ctx , jobID )
if err != nil {
return nil , err
}
fmt . Printf ( "Job status: %s ( %d%% complete) \n " ,
job . GetStatus (),
job . GetPercentageDone ())
switch job . GetStatus () {
case "completed" :
return job , nil
case "failed" :
return nil , fmt . Errorf ( "job failed: %s " , job . GetStatusDetails ())
}
}
}
}
func main () {
managementClient , err := management . New (
"yourtenant.auth0.com" ,
management . WithClientCredentials ( clientID , clientSecret ),
)
if err != nil {
log . Fatal ( err )
}
ctx := context . Background ()
// Start a user export
job , err := managementClient . Jobs . UsersExports . Create ( ctx , & management . CreateUsersExportRequest {
Format : auth0 . String ( "json" ),
})
if err != nil {
log . Fatal ( err )
}
fmt . Printf ( "Started export job: %s \n " , job . GetID ())
// Wait for completion
completedJob , err := waitForJob ( ctx , managementClient , job . GetID ())
if err != nil {
log . Fatal ( err )
}
fmt . Printf ( "Export completed! Download from: %s \n " , completedJob . GetLocation ())
// Print summary
summary := completedJob . GetSummary ()
fmt . Printf ( "Total: %d , Inserted: %d , Updated: %d , Failed: %d \n " ,
summary . GetTotal (),
summary . GetInserted (),
summary . GetUpdated (),
summary . GetFailed ())
}
Job Status Values
pending : Job has been queued but not started
processing : Job is currently running
completed : Job finished successfully
failed : Job encountered an error
Job Types
users_export : Export users to a file
users_import : Import users from a file
verification_email : Send email verification
password_change : Password change notification