# Branch Management

# Introduction

In branch management, you can create, edit, fetch, or delete branches.

# Create branch

To create a branch, you will need to make an HTTP POST request to the following endpoint:

POST
https://api.armadadelivery.com/v1/branches

The body of the request should be in JSON format and include the following parameters:

  • name: Branch name, Between 2 and 75 String - Required
  • phone: Branch phone number String - Required
  • address: The branch address Object - Required
    • location: Geo-location address Object - Required
      • latitude: Float - Required
      • longitude: Float - Required
    • first_line: A Complete Regular Address, It's important for drivers as a human readable address String - Optional

# Request Example

curl --location --request POST 'https://api.armadadelivery.com/v1/branches' \
--header 'Armada-Access-Token: [YOUR ACCESS TOKEN]' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "NAQSH",
    "phone": "+96500000000",
    "address": {
        "location":{
	        "latitude": 29.192375,
	        "longitude": 48.111894
		},
        "first_line": "Abu Hassaniah, Block 10, St 60, 36B"
    }
}'
const accessToken = '[YOUR ACCESS TOKEN]'; // Replace with your actual Access Token

fetch('https://api.armadadelivery.com/v1/branches', {
  method: 'POST',
  headers: {
    'Armada-Access-Token': accessToken,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "name": "NAQSH",
    "phone": "+96500000000",
    "address": {
      "location": {
        "latitude": 29.192375,
        "longitude": 48.111894,
      },
      "first_line": "Abu Hassaniah, Block 10, St 60, 36B"
    }
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
func main() {
	accessToken := "[YOUR ACCESS TOKEN]" // Replace with your actual Access Token
	url := "https://api.armadadelivery.com/v1/branches"

	data := map[string]interface{}{
		"name": "NAQSH",
		"phone": "+96500000000",
		"address": map[string]interface{}{
			"location": map[string]float64{
				"latitude":  29.192375,
				"longitude": 48.111894,
			},
			"first_line": "Abu Hassaniah, Block 10, St 60, 36B",
		},
	}

	jsonData, err := json.Marshal(data)
	if err != nil {
		fmt.Println("Error encoding JSON:", err)
		return
	}

	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
	if err != nil {
		fmt.Println("Error creating request:", err)
		return
	}

	req.Header.Set("Armada-Access-Token", accessToken)
	req.Header.Set("Content-Type", "application/json")
	// ...
}

The response will include the details from your request body, along with the _id associated with the branch.

# Response Schema

{
  "_id": "String",
  "phone": "String",
  "name": "String",
  "address": {
    "location": {
      "latitude": "Number",
      "longitude": "Number"
    },
    "first_line": "String"
  }
}

# Get branch

To get one branch, you will need to make an HTTP GET request to the following endpoint:

https://api.armadadelivery.com/v1/branches/:id
  • id: Parameter, The branch ID String - Required

# Request Example

(e.g id = 5eef2043bfa02f001c17b229)

curl --location --request GET 'https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229' \
--header 'Armada-Access-Token: [YOUR ACCESS TOKEN]'
fetch('https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229', {
    method: 'GET',
    headers: {
        'Armada-Access-Token': '[YOUR ACCESS TOKEN]',
    }
})
.then(response => response.json())
.then((data) => console.log(data))
.catch((error) => console.error('Error:', error));
func main() {
    req, err := http.NewRequest("GET", "https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229", nil)
    if err != nil {
        fmt.Println(err)
    }
    req.Header.Set("Armada-Access-Token", "[YOUR ACCESS TOKEN]")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}

# Response Schema

{
  "_id": "String",
  "phone": "String",
  "name": "String",
  "address": {
    "location": {
      "latitude": "Number",
      "longitude": "Number"
    },
    "first_line": "String"
  }
}

# Get all branches

To get all branches, you will need to make an HTTP GET request to the following endpoint:

https://api.armadadelivery.com/v1/branches

# Request Example

curl --location --request GET 'https://api.armadadelivery.com/v1/branches' \
--header 'Armada-Access-Token: [YOUR ACCESS TOKEN]'
fetch('https://api.armadadelivery.com/v1/branches', {
    method: 'GET',
    headers: {
        'Armada-Access-Token': '[YOUR ACCESS TOKEN]',
    }
})
.then(response => response.json())
.then((data) => console.log(data))
.catch((error) => console.error('Error:', error));
func main() {
    req, err := http.NewRequest("GET", "https://api.armadadelivery.com/v1/branches", nil)
    if err != nil {
        fmt.Println(err)
    }
    req.Header.Set("Armada-Access-Token", "[YOUR ACCESS TOKEN]")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}

# Response Schema

You will get an array of data:

[
  {
    "_id": "String",
    "phone": "String",
    "name": "String",
    "address": {
      "location": {
        "latitude": "Number",
        "longitude": "Number"
      },
      "first_line": "String"
    }
  },
  // ...
]

# Update branch

To update a branch, you will need to make an HTTP PUT request to the following endpoint:

https://api.armadadelivery.com/v1/branches/:id
  • id: Parameter, The branch ID String - Required

The body of the request should be in JSON format and include one of the following parameters:

  • name: Branch name, Between 2 and 75 String - Optional
  • phone: Branch phone number String - Optional
  • address: The branch address Object - Optional
    • location: Geo-location address Object - Optional
      • latitude: Float
      • longitude: Float
    • first_line: A Complete Regular Address, It's important for drivers as a human readable address String - Optional

# Request Example

(e.g id = 5eef2043bfa02f001c17b229)

curl --location --request PUT 'https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229' \
--header 'Armada-Access-Token: [YOUR ACCESS TOKEN]' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "Alhambra Grill"
}'
fetch('https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229', {
    method: 'PUT',
    headers: {
         'Armada-Access-Token': '[YOUR ACCESS TOKEN]',
         'Content-Type': 'application/json'
     },
    body: JSON.stringify({
        "name": "Alhambra Grill"
    })
})
.then(response => response.json())
.then((data) => console.log(data))
.catch((error) => console.error('Error:', error));
func main() {
    jsonData := []byte(`{
        "name": "Alhambra Grill"
    }`)
    req, err := http.NewRequest("PUT", "https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229", bytes.NewBuffer(jsonData))
    if err != nil {
        fmt.Println("Error:", err)
    }
    req.Header.Set("Armada-Access-Token", "[YOUR ACCESS TOKEN]")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}

# Response Schema

{
  "_id": "String",
  "phone": "String",
  "name": "String",
  "address": {
    "location": {
      "latitude": "Number",
      "longitude": "Number"
    },
    "first_line": "String"
  }
}

# Delete branch

To delete a branch, you will need to make an HTTP DELETE request to the following endpoint:

https://api.armadadelivery.com/v1/branches/:id
  • id: Parameter, The branch ID String - Required

# Request Example

(e.g id = 5eef2043bfa02f001c17b229)

curl --location --request DELETE 'https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229' \
--header 'Armada-Access-Token: [YOUR ACCESS TOKEN]'
fetch('https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229', {
    method: 'DELETE',
    headers: {
        'Armada-Access-Token': '[YOUR ACCESS TOKEN]',
    }
})
.then(response => response.json())
.then((data) => console.log(data))
.catch((error) => console.error('Error:', error));
func main() {
    req, err := http.NewRequest("DELETE", "https://api.armadadelivery.com/v1/branches/5eef2043bfa02f001c17b229", nil)
    if err != nil {
        fmt.Println(err)
    }
    req.Header.Set("Armada-Access-Token", "[YOUR ACCESS TOKEN]")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println(err)
    }
    defer resp.Body.Close()
}

# Response

If successful, expect a response with HTTP status code 204.