Jenkins REST API Create job Jenkins REST API Create job jenkins jenkins

Jenkins REST API Create job


Jenkins by default has CSRF Protection enabled which prevents one-click attacks. To invoke the request, you need to obtain the crumb from /crumbIssuer/api/xml using your credentials and include it into your request.

For example:

CRUMB=$(curl -s 'http://USER:TOKEN@localhost:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')

Then you can create a job (by including the crumb into your header):

curl -X POST -H "$CRUMB" "http://USER:TOKEN@localhost:8080/createItem?name=NewJob"

If the above won't work, check your crumb (echo $CRUMB) or run curl with -u USER:TOKEN.

For a more detailed explanation, see: Running jenkins jobs via command line.


If you are using Postman to fire the requests, using @kenorb example above, get the crumbenter image description here

To create a folder at root level using the createItem endpointenter image description here

To create a sub-folder inside the folder created above using the createItem endpointenter image description here