Question: We would like to replace an existing deployment of our app.war with curl. The post below gives a nice way to deploy a war file. This works well as long as there is no war file deployed with the same name. It fails, however, if there is already a deployment present. Is there any way we can replace the existing deployment via curl?

<http://blog.arungupta.me/2014/01/deploy-to-wildfly-using-curl-tech-tip-10/>

Is there a way to get the complete interface documentation of the HTTP API of wildfly

Answer: 
Many thanks to @nioe for the script! Here's a configurable version with silenced `curl` better suited for CI scripting:

```sh
#!/bin/bash

# Deploys given WAR to WildFly server, pass full path to WAR as argument

set -e
set -u

[[ -f "$1" ]] || { >&2 echo "Usage: $0 WAR-filename ('$1' is not a file)"; exit 1; }

WILDFLY_MANAGEMENT_URL=http://username:password@hostname:9990
WAR_NAME=`basename $1`
WAR_PATH=`dirname $1`

echo "Deploying '$WAR_NAME' from '$WAR_PATH' to '$WILDFLY_MANAGEMENT_URL'"
echo '-------------------'

echo "-> Undeploy old war"
curl -sS -H "content-Type: application/json" -d '{"operation":"undeploy", "address":[{"deployment":"'"${WAR_NAME}"'"}]}' --digest ${WILDFLY_MANAGEMENT_URL}/management
echo ""

echo "-> Remove old war"
curl -sS -H "content-Type: application/json" -d '{"operation":"remove", "address":[{"deployment":"'"${WAR_NAME}"'"}]}' --digest ${WILDFLY_MANAGEMENT_URL}/management
echo ""

echo "-> Upload new war"
bytes_value=`curl -sF "file=@${WAR_PATH}/${WAR_NAME}" --digest ${WILDFLY_MANAGEMENT_URL}/management/add-content | perl -pe 's/^.*"BYTES_VALUE"\s*:\s*"(.*)".*$/$1/'`
echo $bytes_value

json_string_start='{"content":[{"hash": {"BYTES_VALUE" : "'
json_string_end='"}}], "address": [{"deployment":"'"${WAR_NAME}"'"}], "operation":"add", "enabled":"true"}'
json_string="$json_string_start$bytes_value$json_string_end"

echo "-> Deploy new war"
result=`curl -sS -H "Content-Type: application/json" -d "$json_string" --digest ${WILDFLY_MANAGEMENT_URL}/management | perl -pe 's/^.*"outcome"\s*:\s*"(.*)".*$/$1/'`
echo $result

if [ "$result" != "success" ]; then
  exit -1
fi

```
Take a look at documentation of whole management model at

<http://wildscribe.github.io/>

There is no direct operation that would replace deployment.

[See](http://wildscribe.github.io/Wildfly/8.0.0.Final/deployment/index.html) possible attribute/operations for deployment resource

So what you could do is remove deployment if there is any, and then add new one.
or you could add new deployment under new name, disable old one and enable new one.

There are many options you could do.
For start I would recommend you to take a look at jboss-cli
by simply connecting to default instance on server by starting `jboss-cli.sh|bat -c` in bin folder.

By navigating CLI you can find also whole set of attributes/operations/resources that you can manipulate

some docs on this topic 

<https://docs.jboss.org/author/display/WFLY8/CLI+Recipes>

<https://docs.jboss.org/author/display/WFLY8/Management+API+reference>