@Transactional
    public void deleteAllContracts(String organizationId, String clientId, String version)
        throws ClientNotFoundException, NotAuthorizedException {

        ArrayList<ContractBean> contractsToDelete = Lists.newArrayList(tryAction(() -> storage.getAllContracts(organizationId, clientId, version)));
        try {
            if (!contractsToDelete.isEmpty()) {
                // Need to unregister client if in Registered or AwaitingApproval state
                ClientStatus clientStatus = contractsToDelete.get(0).getClient().getStatus();
                if (clientStatus == ClientStatus.Registered || clientStatus == ClientStatus.AwaitingApproval) {
                    actionService.unregisterClient(organizationId, clientId, version);
                }
            }
            deleteContractsInternal(organizationId, clientId, version, contractsToDelete, contractsToDelete);
        } catch (Exception e) {
            throw new SystemErrorException(e);
        }
    }
Check to see if the contract already exists, by getting a list of all the
client's contracts and comparing with the one being created.
manager/api/rest-impl/src/main/java/io/apiman/manager/api/service/ContractService.java